Bug 463 - Moved xhtml header emission into each file to avoid inadvertent prepending of video downloads. Also autogenerate mime-type.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2314 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2008-02-20 23:11:25 +00:00
parent 6acbc11296
commit 5ea3f88b18
16 changed files with 76 additions and 6 deletions

View File

@ -166,6 +166,22 @@ function getStreamSrc( $args )
return( $stream_src ); return( $stream_src );
} }
function getMimeType( $file )
{
if ( function_exists('mime_content_type ') )
{
return( mime_content_type( $file ) );
}
elseif ( function_exists('finfo_file ') )
{
$finfo = finfo_open( FILEINFO_MIME );
$mimetype = finfo_file( $finfo, $file );
finfo_close($finfo);
return( $mimetype );
}
return( trim( exec( 'file -bi '.escapeshellarg( $file ) ) ) );
}
function outputVideoStream( $src, $width, $height, $name, $format ) function outputVideoStream( $src, $width, $height, $name, $format )
{ {
switch ( $format ) switch ( $format )

View File

@ -45,12 +45,6 @@ require_once( 'zm_lang.php' );
require_once( 'zm_funcs.php' ); require_once( 'zm_funcs.php' );
require_once( 'zm_xhtml_config.php' ); require_once( 'zm_xhtml_config.php' );
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
echo( '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">'."\n" );
ob_start(); ob_start();
if ( !isset($user) && ZM_OPT_USE_AUTH ) if ( !isset($user) && ZM_OPT_USE_AUTH )

View File

@ -83,7 +83,12 @@ for ( $i = 0; $i < count($monitors); $i++ )
} }
$monitors[$i] = array_merge( $monitors[$i], $counts ); $monitors[$i] = array_merge( $monitors[$i], $counts );
} }
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangConsole ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangConsole ?></title>

View File

@ -25,7 +25,12 @@ foreach ( dbFetchAll( $sql ) as $row )
$row['Status'] = getDeviceStatusX10( $row['KeyString'] ); $row['Status'] = getDeviceStatusX10( $row['KeyString'] );
$devices[] = $row; $devices[] = $row;
} }
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangDevices ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangDevices ?></title>

View File

@ -18,7 +18,11 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// //
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangError ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangError ?></title>

View File

@ -81,7 +81,11 @@ $frames_per_line = 3;
$paged = $event['Frames'] > $frames_per_page; $paged = $event['Frames'] > $frames_per_page;
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangEvent ?> - <?= $event['Name'] ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangEvent ?> - <?= $event['Name'] ?></title>

View File

@ -75,7 +75,11 @@ function getThumbnail( $event, $fid, $scale )
return( $thumb_image ); return( $thumb_image );
} }
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangEvent ?> <?= $eid ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangEvent ?> <?= $eid ?></title>

View File

@ -90,7 +90,11 @@ elseif ( !empty( $limit ) )
$events_sql .= " limit 0, $limit"; $events_sql .= " limit 0, $limit";
} }
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangEvents ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangEvents ?></title>

View File

@ -30,7 +30,11 @@ foreach( dbFetchAll( $sql ) as $row )
$filter_names[$row['Name']] = $row['Name']; $filter_names[$row['Name']] = $row['Name'];
} }
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangEventFilter ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangEventFilter ?></title>

View File

@ -50,7 +50,11 @@ $image_data = getImageSrc( $event, $frame, $scale, (isset($show)&&$show=="capt")
$image_path = $image_data['thumbPath']; $image_path = $image_data['thumbPath'];
$event_path = $image_data['eventPath']; $event_path = $image_data['eventPath'];
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangFrame ?> <?= $eid."-".$fid ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangFrame ?> <?= $eid."-".$fid ?></title>

View File

@ -25,7 +25,11 @@ if ( !canEdit( 'Monitors' ) )
} }
$monitor = dbFetchMonitor( $mid ); $monitor = dbFetchMonitor( $mid );
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangFunction ?> - <?= $monitor['Name'] ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangFunction ?> - <?= $monitor['Name'] ?></title>

View File

@ -18,7 +18,10 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// //
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangLogin ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangLogin ?></title>

View File

@ -43,7 +43,11 @@ foreach( dbFetchAll( $sql ) as $row )
$monitors[] = $row; $monitors[] = $row;
} }
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangMontage ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangMontage ?></title>

View File

@ -27,7 +27,11 @@ $running = daemonCheck();
$status = dbFetchAll( "select * from States" ); $status = dbFetchAll( "select * from States" );
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangState ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangState ?></title>

View File

@ -123,12 +123,18 @@ if ( $dir = opendir( $event_path ) )
if ( isset($download) ) if ( isset($download) )
{ {
header( "Content-type: ".getMimeType($video_files[$download]));
header( "Content-length: ".filesize($video_files[$download]));
header( "Content-disposition: attachment; filename=".preg_replace( "/^.*\//", "", $video_files[$download] )."; size=".filesize($video_files[$download]) ); header( "Content-disposition: attachment; filename=".preg_replace( "/^.*\//", "", $video_files[$download] )."; size=".filesize($video_files[$download]) );
readfile( $video_files[$download] ); readfile( $video_files[$download] );
exit; exit;
} }
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangVideo ?> - <?= $event['Name'] ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangVideo ?> - <?= $event['Name'] ?></title>

View File

@ -83,7 +83,12 @@ $prev_mid = $mon_idx==0?$mon_index[(count($monitors)-1)]['Id']:$monitors[$mon_id
$scale = getDeviceScale( $monitor['Width'], $monitor['Height'] ); $scale = getDeviceScale( $monitor['Width'], $monitor['Height'] );
$image_src = getStreamSrc( array( "mode=single", "monitor=".$monitor['Id'], "scale=".$scale ) ); $image_src = getStreamSrc( array( "mode=single", "monitor=".$monitor['Id'], "scale=".$scale ) );
noCacheHeaders();
header("Content-type: application/xhtml+xml" );
echo( '<?xml version="1.0" encoding="iso-8859-1"?>'."\n" );
?> ?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $monitor['Name'] ?> - <?= $zmSlangWatch ?></title> <title><?= ZM_WEB_TITLE_PREFIX ?> - <?= $monitor['Name'] ?> - <?= $zmSlangWatch ?></title>