diff --git a/web/skins/classic/views/video.php b/web/skins/classic/views/video.php index cfbb6f929..be198177c 100644 --- a/web/skins/classic/views/video.php +++ b/web/skins/classic/views/video.php @@ -17,96 +17,74 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // - -if ( !canView( 'Events' ) ) -{ - $view = "error"; - return; +if ( !canView( 'Events' ) ) { + $view = "error"; + return; } - +require_once('includes/Event.php'); $eid = validInt($_REQUEST['eid']); - $sql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultRate,M.DefaultScale FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?'; $sql_values = array( $eid ); - if ( $user['MonitorIds'] ) { - $monitor_ids = explode( ',', $user['MonitorIds'] ); - $sql .= ' AND MonitorId IN (' .implode( ',', array_fill(0,count($monitor_ids),'?') ) . ')'; - $sql_values = array_merge( $sql_values, $monitor_ids ); + $monitor_ids = explode( ',', $user['MonitorIds'] ); + $sql .= ' AND MonitorId IN (' .implode( ',', array_fill(0,count($monitor_ids),'?') ) . ')'; + $sql_values = array_merge( $sql_values, $monitor_ids ); } $event = dbFetchOne( $sql, NULL, $sql_values ); - if ( isset( $_REQUEST['rate'] ) ) - $rate = validInt($_REQUEST['rate']); + $rate = validInt($_REQUEST['rate']); else - $rate = reScale( RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE ); + $rate = reScale( RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE ); if ( isset( $_REQUEST['scale'] ) ) - $scale = validInt($_REQUEST['scale']); + $scale = validInt($_REQUEST['scale']); else - $scale = reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); - -$eventPath = ZM_DIR_EVENTS.'/'.getEventPath( $event ); - + $scale = reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); +$Event = new Event( $event['Id'] ); +$eventPath = $Event->Path(); $videoFormats = array(); $ffmpegFormats = preg_split( '/\s+/', ZM_FFMPEG_FORMATS ); -foreach ( $ffmpegFormats as $ffmpegFormat ) -{ - if ( preg_match( '/^([^*]+)(\*\*?)$/', $ffmpegFormat, $matches ) ) - { - $videoFormats[$matches[1]] = $matches[1]; - if ( !isset($videoFormat) && $matches[2] == "*" ) - { - $videoFormat = $matches[1]; - } - } - else - { - $videoFormats[$ffmpegFormat] = $ffmpegFormat; +foreach ( $ffmpegFormats as $ffmpegFormat ) { + if ( preg_match( '/^([^*]+)(\*\*?)$/', $ffmpegFormat, $matches ) ) { + $videoFormats[$matches[1]] = $matches[1]; + if ( !isset($videoFormat) && $matches[2] == '*' ) { + $videoFormat = $matches[1]; } + } else { + $videoFormats[$ffmpegFormat] = $ffmpegFormat; + } } - $videoFiles = array(); -if ( $dir = opendir( $eventPath ) ) -{ - while ( ($file = readdir( $dir )) !== false ) - { - $file = $eventPath.'/'.$file; - if ( is_file( $file ) ) - { - if ( preg_match( '/\.(?:'.join( '|', $videoFormats ).')$/', $file ) ) - { - $videoFiles[] = $file; - } - } +if ( $dir = opendir( $eventPath ) ) { + while ( ($file = readdir( $dir )) !== false ) { + $file = $eventPath.'/'.$file; + if ( is_file( $file ) ) { + if ( preg_match( '/\.(?:'.join( '|', $videoFormats ).')$/', $file ) ) { + $videoFiles[] = $file; + } } - closedir( $dir ); + } + closedir( $dir ); } - -if ( isset($_REQUEST['deleteIndex']) ) -{ - $deleteIndex = validInt($_REQUEST['deleteIndex']); - unlink( $videoFiles[$deleteIndex] ); - unset( $videoFiles[$deleteIndex] ); +if ( isset($_REQUEST['deleteIndex']) ) { + $deleteIndex = validInt($_REQUEST['deleteIndex']); + unlink( $videoFiles[$deleteIndex] ); + unset( $videoFiles[$deleteIndex] ); } - -if ( isset($_REQUEST['downloadIndex']) ) -{ - $downloadIndex = validInt($_REQUEST['downloadIndex']); - header( "Pragma: public" ); - header( "Expires: 0" ); - header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); - header( "Cache-Control: private", false ); // required by certain browsers - header( "Content-Description: File Transfer" ); - header( 'Content-disposition: attachment; filename="'.basename($videoFiles[$downloadIndex]).'"' ); // basename is required because the video index contains the path and firefox doesn't strip the path but simply replaces the slashes with an underscore. - header( "Content-Transfer-Encoding: binary" ); - header( "Content-Type: application/force-download" ); - header( "Content-Length: ".filesize($videoFiles[$downloadIndex]) ); - readfile( $videoFiles[$downloadIndex] ); - exit; +if ( isset($_REQUEST['downloadIndex']) ) { + $downloadIndex = validInt($_REQUEST['downloadIndex']); + header( "Pragma: public" ); + header( "Expires: 0" ); + header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); + header( "Cache-Control: private", false ); // required by certain browsers + header( "Content-Description: File Transfer" ); + header( 'Content-disposition: attachment; filename="'.basename($videoFiles[$downloadIndex]).'"' ); // basename is required because the video index contains the path and firefox doesn't strip the path but simply replaces the slashes with an underscore. + header( "Content-Transfer-Encoding: binary" ); + header( "Content-Type: application/force-download" ); + header( "Content-Length: ".filesize($videoFiles[$downloadIndex]) ); + readfile( $videoFiles[$downloadIndex] ); + exit; } - $focusWindow = true; - xhtmlHeaders(__FILE__, translate('Video') ); ?> @@ -119,19 +97,16 @@ xhtmlHeaders(__FILE__, translate('Video') );

@@ -158,29 +133,23 @@ else disabled="disabled"/>

@@ -194,32 +163,24 @@ else 0 ) - { - preg_match( '/^(.+)-((?:r[_\d]+)|(?:F[_\d]+))-((?:s[_\d]+)|(?:S[0-9a-z]+))\.([^.]+)$/', $file, $matches ); - if ( preg_match( '/^r(.+)$/', $matches[2], $temp_matches ) ) - { - $rate = (int)(100 * preg_replace( '/_/', '.', $temp_matches[1] ) ); - $rateText = isset($rates[$rate])?$rates[$rate]:($rate."x"); - } - elseif ( preg_match( '/^F(.+)$/', $matches[2], $temp_matches ) ) - { - $rateText = $temp_matches[1]."fps"; - } - if ( preg_match( '/^s(.+)$/', $matches[3], $temp_matches ) ) - { - $scale = (int)(100 * preg_replace( '/_/', '.', $temp_matches[1] ) ); - $scaleText = isset($scales[$scale])?$scales[$scale]:($scale."x"); - } - elseif ( preg_match( '/^S(.+)$/', $matches[3], $temp_matches ) ) - { - $scaleText = $temp_matches[1]; - } - $width = $scale?reScale( $event['Width'], $scale ):$event['Width']; - $height = $scale?reScale( $event['Height'], $scale ):$event['Height']; + $index = 0; + foreach ( $videoFiles as $file ) { + if ( filesize( $file ) > 0 ) { + preg_match( '/^(.+)-((?:r[_\d]+)|(?:F[_\d]+))-((?:s[_\d]+)|(?:S[0-9a-z]+))\.([^.]+)$/', $file, $matches ); + if ( preg_match( '/^r(.+)$/', $matches[2], $temp_matches ) ) { + $rate = (int)(100 * preg_replace( '/_/', '.', $temp_matches[1] ) ); + $rateText = isset($rates[$rate])?$rates[$rate]:($rate."x"); + } elseif ( preg_match( '/^F(.+)$/', $matches[2], $temp_matches ) ) { + $rateText = $temp_matches[1]."fps"; + } + if ( preg_match( '/^s(.+)$/', $matches[3], $temp_matches ) ) { + $scale = (int)(100 * preg_replace( '/_/', '.', $temp_matches[1] ) ); + $scaleText = isset($scales[$scale])?$scales[$scale]:($scale."x"); + } elseif ( preg_match( '/^S(.+)$/', $matches[3], $temp_matches ) ) { + $scaleText = $temp_matches[1]; + } + $width = $scale?reScale( $event['Width'], $scale ):$event['Width']; + $height = $scale?reScale( $event['Height'], $scale ):$event['Height']; ?> @@ -229,14 +190,14 @@ else
 /  /