2003-07-11 17:27:56 +08:00
< ? php
2004-01-08 19:45:57 +08:00
//
// ZoneMinder web event view file, $Date$, $Revision$
2005-02-24 22:40:14 +08:00
// Copyright (C) 2003, 2004, 2005 Philip Coombes
2004-01-08 19:45:57 +08:00
//
// 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 2
// 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, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
2003-07-11 17:27:56 +08:00
2004-01-08 19:45:57 +08:00
if ( ! canView ( 'Events' ) )
{
$view = " error " ;
return ;
}
if ( ! isset ( $mode ) )
{
2005-10-19 21:30:05 +08:00
if ( ZM_WEB_USE_STREAMS && canStream () )
2004-01-08 19:45:57 +08:00
$mode = " stream " ;
else
$mode = " still " ;
}
2003-07-11 17:27:56 +08:00
2004-03-10 01:07:09 +08:00
if ( $user [ 'MonitorIds' ] )
{
$mid_sql = " and MonitorId in ( " . join ( " , " , preg_split ( '/["\'\s]*,["\'\s]*/' , $user [ 'MonitorIds' ] ) ) . " ) " ;
}
else
{
$mid_sql = '' ;
}
2005-11-22 19:21:27 +08:00
$sql = " select E.*,M.Name as MonitorName,M.Width,M.Height,M.DefaultRate,M.DefaultScale from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = ' $eid ' $mid_sql " ;
2004-03-10 22:23:22 +08:00
$result = mysql_query ( $sql );
2004-01-08 19:45:57 +08:00
if ( ! $result )
die ( mysql_error () );
$event = mysql_fetch_assoc ( $result );
2006-01-12 23:41:39 +08:00
mysql_free_result ( $result );
2003-07-11 17:27:56 +08:00
2004-03-10 22:23:22 +08:00
parseSort ();
parseFilter ();
2004-03-10 01:07:09 +08:00
2004-09-24 06:21:05 +08:00
$sql = " select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where $sort_column " . ( $sort_order == 'asc' ? '<=' : '>=' ) . " ' " . $event [ preg_replace ( '/^.*\./' , '' , $sort_column )] . " ' $filter_sql $mid_sql order by $sort_column " . ( $sort_order == 'asc' ? 'desc' : 'asc' );
2004-03-10 22:23:22 +08:00
$result = mysql_query ( $sql );
2004-01-08 19:45:57 +08:00
if ( ! $result )
die ( mysql_error () );
2004-03-10 22:23:22 +08:00
while ( $row = mysql_fetch_assoc ( $result ) )
{
if ( $row [ Id ] == $eid )
{
$prev_event = mysql_fetch_assoc ( $result );
break ;
}
}
2006-01-12 23:41:39 +08:00
mysql_free_result ( $result );
2004-01-08 19:45:57 +08:00
2004-09-24 06:21:05 +08:00
$sql = " select E.* from Events as E inner join Monitors as M on E.MonitorId = M.Id where $sort_column " . ( $sort_order == 'asc' ? '>=' : '<=' ) . " ' " . $event [ preg_replace ( '/^.*\./' , '' , $sort_column )] . " ' $filter_sql $mid_sql order by $sort_column $sort_order " ;
2004-03-10 22:23:22 +08:00
$result = mysql_query ( $sql );
2004-01-08 19:45:57 +08:00
if ( ! $result )
die ( mysql_error () );
2004-03-10 22:23:22 +08:00
while ( $row = mysql_fetch_assoc ( $result ) )
{
if ( $row [ Id ] == $eid )
{
$next_event = mysql_fetch_assoc ( $result );
break ;
}
}
2006-01-12 23:41:39 +08:00
mysql_free_result ( $result );
2004-01-08 19:45:57 +08:00
if ( ! isset ( $rate ) )
2005-11-22 19:21:27 +08:00
$rate = reScale ( RATE_SCALE , $event [ 'DefaultRate' ], ZM_WEB_DEFAULT_RATE );
2004-01-08 19:45:57 +08:00
if ( ! isset ( $scale ) )
2005-10-20 00:52:28 +08:00
$scale = reScale ( SCALE_SCALE , $event [ 'DefaultScale' ], ZM_WEB_DEFAULT_SCALE );
2006-01-01 04:12:24 +08:00
if ( $mode == " still " && $scale < SCALE_SCALE )
$scale = SCALE_SCALE ;
2003-07-11 17:27:56 +08:00
2006-01-01 04:12:24 +08:00
$frames_per_line = reScale ( ZM_WEB_FRAMES_PER_LINE , $scale );
$frames_per_page = reScale ( $frames_per_line * ZM_WEB_FRAME_LINES , $scale );
2003-11-14 18:28:17 +08:00
2004-01-08 19:45:57 +08:00
$paged = $event [ 'Frames' ] > $frames_per_page ;
2003-11-14 18:28:17 +08:00
2006-01-12 23:41:39 +08:00
if ( $mode == " stream " )
{
$sql = " select max(Delta)-min(Delta) as Duration from Frames where EventId = ' $eid ' " ;
$result = mysql_query ( $sql );
if ( ! $result )
die ( mysql_error () );
$frame_data = mysql_fetch_assoc ( $result );
mysql_free_result ( $result );
$frame_data [ 'RealDuration' ] = ( $frame_data [ 'Duration' ] * RATE_SCALE ) / $rate ;
$panel_init_color = '#eeeeee' ;
$panel_done_color = '#aaaaaa' ;
$panel_border_color = '#666666' ;
$panel_divider_color = '#999999' ;
$panel_sections = 40 ;
$panel_section_width = ( int ) ceil ( $event [ 'Width' ] / $panel_sections );
$panel_width = ( $panel_sections * $panel_section_width - 1 );
//$panel_section_width = 10;
//$panel_sections = ((int)($event['Width']/$panel_section_width))+1;
//$panel_width = $panel_sections*$panel_section_width;
$panel_timeout = ( int )((( $frame_data [ 'RealDuration' ] + 1 ) * 1000 ) / $panel_sections );
}
ob_start ();
2003-07-11 17:27:56 +08:00
?>
2004-12-29 03:22:23 +08:00
<! DOCTYPE HTML PUBLIC " -//W3C//DTD HTML 4.01 Transitional//EN " >
2003-07-11 17:27:56 +08:00
< html >
< head >
2005-05-06 20:24:57 +08:00
< title >< ? = ZM_WEB_TITLE_PREFIX ?> - <?= $zmSlangEvent ?> - <?= $event['Name'] ?></title>
2004-12-29 02:20:11 +08:00
< link rel = " stylesheet " href = " zm_html_styles.css " type = " text/css " >
2004-12-29 03:29:43 +08:00
< script type = " text/javascript " >
2003-07-11 17:27:56 +08:00
< ? php
2004-01-08 19:45:57 +08:00
if ( ! $event )
{
2003-07-11 17:27:56 +08:00
?>
opener . location . reload ( true );
window . close ();
< ? php
2004-01-08 19:45:57 +08:00
}
2003-07-11 17:27:56 +08:00
?>
window . focus ();
< ? php
2004-01-08 19:45:57 +08:00
if ( ! empty ( $refresh_parent ) )
{
2003-07-11 17:27:56 +08:00
?>
opener . location . reload ( true );
< ? php
2004-01-08 19:45:57 +08:00
}
2003-07-11 17:27:56 +08:00
?>
function refreshWindow ()
{
window . location . reload ( true );
}
function closeWindow ()
{
window . close ();
}
function newWindow ( Url , Name , Width , Height )
{
2005-10-17 05:09:56 +08:00
var Win = window . open ( Url , Name , " resizable,width= " + Width + " ,height= " + Height );
2003-07-11 17:27:56 +08:00
}
2004-09-24 06:21:05 +08:00
< ? php
2006-01-12 23:41:39 +08:00
if ( $mode == " stream " )
2004-09-24 06:21:05 +08:00
{
2006-01-12 23:41:39 +08:00
?>
function incrementPanel ( section )
{
document . getElementById ( 'PanelSection' + section ) . style . backgroundColor = '<?= $panel_done_color ?>' ;
section ++ ;
if ( section < < ? = $panel_sections ?> )
{
window . setTimeout ( " incrementPanel( " + section + " ) " , < ? = $panel_timeout ?> );
}
}
2004-09-24 06:21:05 +08:00
< ? php
}
?>
2003-07-11 17:27:56 +08:00
</ script >
2006-01-12 23:41:39 +08:00
< ? php
if ( $mode == " stream " )
{
?>
< style type = " text/css " >
<!--
#Panel {
position : relative ;
text - align : center ;
border : 1 px solid < ? = $panel_border_color ?> ;
height : 15 px ;
width : < ? = $panel_width ?> px;
padding : 0 px ;
margin : auto ;
}
#Panel div.Section {
position : absolute ;
height : 15 px ;
}
-->
</ style >
< ? php
}
?>
2003-07-11 17:27:56 +08:00
</ head >
2003-12-16 22:56:36 +08:00
< body scroll = " auto " >
2003-07-11 17:27:56 +08:00
< table border = " 0 " cellspacing = " 0 " cellpadding = " 4 " width = " 100% " >
< tr >
2005-05-18 06:18:14 +08:00
< td >< table border = " 0 " cellspacing = " 0 " cellpadding = " 2 " width = " 100% " >
< tr >
< td align = " left " class = " text " >
2003-07-11 17:27:56 +08:00
< form name = " rename_form " method = " get " action = " <?= $PHP_SELF ?> " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
< input type = " hidden " name = " action " value = " rename " >
2006-01-01 04:12:24 +08:00
< input type = " hidden " name = " mode " value = " <?= $mode ?> " >
2003-07-11 17:27:56 +08:00
< input type = " hidden " name = " eid " value = " <?= $eid ?> " >
2004-04-21 17:20:28 +08:00
< ? = $filter_fields ?>
< input type = " hidden " name = " sort_field " value = " <?= $sort_field ?> " >
< input type = " hidden " name = " sort_asc " value = " <?= $sort_asc ?> " >
< input type = " hidden " name = " limit " value = " <?= $limit ?> " >
< input type = " hidden " name = " rate " value = " <?= $rate ?> " >
< input type = " hidden " name = " scale " value = " <?= $scale ?> " >
< input type = " hidden " name = " page " value = " <?= $page ?> " >
2004-01-08 18:09:35 +08:00
< input type = " text " size = " 16 " name = " event_name " value = " <?= $event['Name'] ?> " class = " form " >
2004-01-07 20:57:07 +08:00
< input type = " submit " value = " <?= $zmSlangRename ?> " class = " form " < ? php if ( ! canEdit ( 'Events' ) ) { ?> disabled<?php } ?>></form></td>
2003-10-16 17:02:07 +08:00
< ? php if ( 0 ) { ?>
2005-05-18 06:18:14 +08:00
< td align = " center " class = " text " >
2003-07-11 17:27:56 +08:00
< form name = " learn_form " method = " get " action = " <?= $PHP_SELF ?> " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
< input type = " hidden " name = " action " value = " learn " >
2006-01-01 04:12:24 +08:00
< input type = " hidden " name = " mode " value = " <?= $mode ?> " >
2003-07-11 17:27:56 +08:00
< input type = " hidden " name = " eid " value = " <?= $eid ?> " >
< input type = " hidden " name = " mark_eid " value = " <?= $eid ?> " >
< ? php if ( LEARN_MODE ) { ?>
2004-01-08 18:09:35 +08:00
Learn Pref :& nbsp ; < select name = " learn_state " class = " form " onChange = " learn_form.submit(); " >< option value = " " < ? php if ( ! $event [ 'LearnState' ] ) echo " selected " ?> ><?= $zmSlangIgnore ?></option><option value="-"<?php if ( $event['LearnState']=='-' ) echo " selected" ?>><?= $zmSlangExclude ?></option><option value="+"<?php if ( $event['LearnState']=='+' ) echo " selected" ?>><?= $zmSlangInclude ?></option></select>
2003-07-11 17:27:56 +08:00
< ? php } ?>
</ form ></ td >
2003-10-16 17:02:07 +08:00
< ? php } ?>
2005-05-18 06:18:14 +08:00
< td align = " right " class = " text " >
2003-10-19 17:47:52 +08:00
< form name = " view_form " method = " get " action = " <?= $PHP_SELF ?> " >
2003-10-10 18:38:30 +08:00
< input type = " hidden " name = " view " value = " <?= $view ?> " >
2006-01-01 04:12:24 +08:00
< input type = " hidden " name = " mode " value = " <?= $mode ?> " >
< input type = " hidden " name = " page " value = " <?= $page ?> " >
2003-10-10 18:38:30 +08:00
< input type = " hidden " name = " eid " value = " <?= $eid ?> " >
2004-03-10 22:23:22 +08:00
< ? = $filter_fields ?>
2004-04-21 17:20:28 +08:00
< input type = " hidden " name = " sort_field " value = " <?= $sort_field ?> " >
< input type = " hidden " name = " sort_asc " value = " <?= $sort_asc ?> " >
< input type = " hidden " name = " limit " value = " <?= $limit ?> " >
2004-01-07 20:57:07 +08:00
< ? = $zmSlangRate ?> : <?= buildSelect( "rate", $rates, "document.view_form.submit();" ); ?>
< ? = $zmSlangScale ?> : <?= buildSelect( "scale", $scales, "document.view_form.submit();" ); ?>
2003-10-10 18:38:30 +08:00
</ form >
</ td >
2003-07-11 17:27:56 +08:00
</ tr >
2005-05-18 06:18:14 +08:00
</ table ></ td ></ tr >
< tr >
< td >< table border = " 0 " cellspacing = " 0 " cellpadding = " 2 " width = " 100% " >
2003-07-11 17:27:56 +08:00
< tr >
2003-11-14 18:28:17 +08:00
< ? php if ( $mode == " stream " ) { ?>
2004-01-07 20:57:07 +08:00
< td align = " center " class = " text " >< a href = " javascript: refreshWindow(); " >< ? = $zmSlangReplay ?> </a></td>
2004-01-08 18:09:35 +08:00
< ? php } elseif ( $paged && ! empty ( $page ) ) { ?>
2006-01-01 04:12:24 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=event&mode=still&eid=<?= $eid ?>&scale=<?= $scale ?><?= $filter_query ?><?= $sort_query ?>&page=0 " >< ? = $zmSlangAll ?> </a></td>
2004-01-08 18:09:35 +08:00
< ? php } elseif ( $paged && empty ( $page ) ) { ?>
2006-01-01 04:12:24 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=event&mode=still&eid=<?= $eid ?>&scale=<?= $scale ?><?= $filter_query ?><?= $sort_query ?>&page=1 " >< ? = $zmSlangPaged ?> </a></td>
2003-11-14 18:28:17 +08:00
< ? php } ?>
2005-05-18 06:18:14 +08:00
< ? php if ( canEdit ( 'Events' ) ) { ?> <td align="center" class="text"><a href="<?= $PHP_SELF ?>?view=none&action=delete&mark_eid=<?= $eid ?>"><?= $zmSlangDelete ?></a></td><?php } ?>
2005-11-11 20:08:38 +08:00
< ? php if ( canEdit ( 'Events' ) ) { ?> <td align="center" class="text"><a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=eventdetail&eid=<?= $eid ?>', 'zmEventDetail', <?= $jws['eventdetail']['w'] ?>, <?= $jws['eventdetail']['h'] ?> )"><?= $zmSlangEdit ?></a></td><?php } ?>
2005-05-18 06:18:14 +08:00
< ? php if ( canEdit ( 'Events' ) ) { ?> <td align="center" class="text"><a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=export&eid=<?= $eid ?>', 'zmExport', <?= $jws['export']['w'] ?>, <?= $jws['export']['h'] ?> )"><?= $zmSlangExport ?></a></td><?php } ?>
< ? php if ( canEdit ( 'Events' ) ) { ?>
2004-01-08 18:09:35 +08:00
< ? php if ( $event [ 'Archived' ] ) { ?>
2005-05-18 06:18:14 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=<?= $view ?>&action=unarchive&eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?> " >< ? = $zmSlangUnarchive ?> </a></td>
2003-07-11 17:27:56 +08:00
< ? php } else { ?>
2005-05-18 06:18:14 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=<?= $view ?>&action=archive&eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?> " >< ? = $zmSlangArchive ?> </a></td>
< ? php } ?>
2003-07-11 17:27:56 +08:00
< ? php } ?>
< ? php if ( $mode == " stream " ) { ?>
2006-01-01 04:12:24 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=event&mode=still&eid=<?= $eid ?>&scale=<?= $scale ?><?= $filter_query ?><?= $sort_query ?>&page=1 " >< ? = $zmSlangStills ?> </a></td>
2003-07-11 17:27:56 +08:00
< ? php } elseif ( canStream () ) { ?>
2004-03-10 22:23:22 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=event&mode=stream&eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?> " >< ? = $zmSlangStream ?> </a></td>
2003-07-11 17:27:56 +08:00
< ? php } ?>
< ? php if ( ZM_OPT_MPEG != " no " ) { ?>
2004-01-08 18:09:35 +08:00
< td align = " center " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=video&eid=<?= $eid ?>', 'zmVideo', <?= $jws['video'] ['w']+ $event['Width'] ?>, <?= $jws['video'] ['h']+ $event['Height'] ?> ); " >< ? = $zmSlangVideo ?> </a></td>
2003-07-11 17:27:56 +08:00
< ? php } ?>
2004-01-07 20:57:07 +08:00
< td align = " right " class = " text " >< a href = " javascript: closeWindow(); " >< ? = $zmSlangClose ?> </a></td>
2003-07-11 17:27:56 +08:00
</ tr >
2005-05-18 06:18:14 +08:00
</ table ></ td ></ tr >
2003-11-14 18:28:17 +08:00
< ? php
2004-01-08 19:45:57 +08:00
if ( $mode == " still " && $paged && ! empty ( $page ) )
{
2003-11-14 18:28:17 +08:00
?>
< ? php
2004-01-08 19:45:57 +08:00
$pages = ( int ) ceil ( $event [ 'Frames' ] / $frames_per_page );
$max_shortcuts = 5 ;
2003-11-14 18:28:17 +08:00
?>
2005-05-18 06:18:14 +08:00
< tr >< td align = " center " class = " text " >
2003-11-14 18:28:17 +08:00
< ? php
2004-01-08 19:45:57 +08:00
if ( $page < 0 )
$page = 1 ;
if ( $page > $pages )
$page = $pages ;
2003-11-14 18:28:17 +08:00
2004-01-08 19:45:57 +08:00
if ( $page > 1 )
{
2005-11-11 20:08:38 +08:00
if ( false && $page > 2 )
{
?>
2006-01-01 04:12:24 +08:00
< a href = " <?= $PHP_SELF ?>?view=event&mode=still&eid=<?= $eid ?>&scale=<?= $scale ?><?= $filter_query ?><?= $sort_query ?>&page=1 " >& lt ; & lt ; </ a >& nbsp ;
2005-11-11 20:08:38 +08:00
< ? php
}
?>
2006-01-01 04:12:24 +08:00
< a href = " <?= $PHP_SELF ?>?view=event&mode=still&eid=<?= $eid ?>&scale=<?= $scale ?><?= $filter_query ?><?= $sort_query ?>&page=<?= $page - 1 ?> " >& lt ; </ a >& nbsp ;
2005-11-11 20:08:38 +08:00
< ? php
2004-01-08 19:45:57 +08:00
$new_pages = array ();
$pages_used = array ();
$lo_exp = max ( 2 , log ( $page - 1 ) / log ( $max_shortcuts ));
for ( $i = 0 ; $i < $max_shortcuts ; $i ++ )
2003-11-14 18:28:17 +08:00
{
2004-01-08 19:45:57 +08:00
$new_page = round ( $page - pow ( $lo_exp , $i ));
if ( isset ( $pages_used [ $new_page ]) )
continue ;
if ( $new_page <= 1 )
break ;
$pages_used [ $new_page ] = true ;
array_unshift ( $new_pages , $new_page );
}
if ( ! isset ( $pages_used [ 1 ]) )
array_unshift ( $new_pages , 1 );
2003-11-14 18:28:17 +08:00
2004-01-08 19:45:57 +08:00
foreach ( $new_pages as $new_page )
{
2003-11-14 18:28:17 +08:00
?>
2006-01-01 04:12:24 +08:00
< a href = " <?= $PHP_SELF ?>?view=event&mode=still&eid=<?= $eid ?>&scale=<?= $scale ?><?= $filter_query ?><?= $sort_query ?>&page=<?= $new_page ?> " >< ? = $new_page ?> </a>
2003-11-14 18:28:17 +08:00
< ? php
}
2004-01-08 19:45:57 +08:00
}
2003-11-14 18:28:17 +08:00
?>
-& nbsp ; < ? = $page ?> -
< ? php
2004-01-08 19:45:57 +08:00
if ( $page < $pages )
{
$new_pages = array ();
$pages_used = array ();
$hi_exp = max ( 2 , log ( $pages - $page ) / log ( $max_shortcuts ));
for ( $i = 0 ; $i < $max_shortcuts ; $i ++ )
2003-11-14 18:28:17 +08:00
{
2004-01-08 19:45:57 +08:00
$new_page = round ( $page + pow ( $hi_exp , $i ));
if ( isset ( $pages_used [ $new_page ]) )
continue ;
if ( $new_page > $pages )
break ;
$pages_used [ $new_page ] = true ;
array_push ( $new_pages , $new_page );
}
if ( ! isset ( $pages_used [ $pages ]) )
array_push ( $new_pages , $pages );
2003-11-14 18:28:17 +08:00
2004-01-08 19:45:57 +08:00
foreach ( $new_pages as $new_page )
{
2003-11-14 18:28:17 +08:00
?>
2006-01-01 04:12:24 +08:00
& nbsp ; < a href = " <?= $PHP_SELF ?>?view=event&mode=still&eid=<?= $eid ?>&scale=<?= $scale ?><?= $filter_query ?><?= $sort_query ?>&page=<?= $new_page ?> " >< ? = $new_page ?> </a>
2005-11-11 20:08:38 +08:00
< ? php
}
?>
2006-01-01 04:12:24 +08:00
& nbsp ; < a href = " <?= $PHP_SELF ?>?view=event&mode=still&eid=<?= $eid ?>&scale=<?= $scale ?><?= $filter_query ?><?= $sort_query ?>&page=<?= $page + 1 ?> " >& gt ; </ a >
2005-11-11 20:08:38 +08:00
< ? php
if ( false && $page < ( $pages - 1 ) )
{
?>
2006-01-01 04:12:24 +08:00
& nbsp ; < a href = " <?= $PHP_SELF ?>?view=event&mode=still&eid=<?= $eid ?>&scale=<?= $scale ?><?= $filter_query ?><?= $sort_query ?>&page=<?= $pages ?> " >& gt ; & gt ; </ a >
2003-11-14 18:28:17 +08:00
< ? php
}
2004-01-08 19:45:57 +08:00
}
2003-11-14 18:28:17 +08:00
?>
</ td ></ tr >
< ? php
2004-01-08 19:45:57 +08:00
}
2003-11-14 18:28:17 +08:00
?>
2003-07-11 17:27:56 +08:00
< ? php
2004-01-08 19:45:57 +08:00
if ( $mode == " stream " )
{
2004-03-04 23:05:54 +08:00
?>
2005-05-18 06:18:14 +08:00
< tr >< td align = " center " valign = " middle " >
2004-03-04 23:05:54 +08:00
< ? php
2004-03-15 07:27:36 +08:00
if ( ZM_VIDEO_STREAM_METHOD == 'mpeg' && ZM_VIDEO_REPLAY_FORMAT )
2003-07-11 17:27:56 +08:00
{
2006-01-12 23:41:39 +08:00
$stream_src = getStreamSrc ( array ( " mode=mpeg " , " event= " . $eid , " frame= " . ( ! empty ( $fid ) ? $fid : 1 ), " scale= " . $scale , " rate= " . $rate , " bitrate= " . ZM_WEB_VIDEO_BITRATE , " maxfps= " . ZM_WEB_VIDEO_MAXFPS , " format= " . ZM_VIDEO_REPLAY_FORMAT ) );
2005-12-08 19:10:44 +08:00
outputVideoStream ( $stream_src , reScale ( $event [ 'Width' ], $scale ), reScale ( $event [ 'Height' ], $scale ), $event [ 'Name' ], ZM_VIDEO_REPLAY_FORMAT );
2004-01-08 19:45:57 +08:00
}
else
{
2006-01-12 23:41:39 +08:00
$stream_src = getStreamSrc ( array ( " mode=jpeg " , " event= " . $eid , " frame= " . ( ! empty ( $fid ) ? $fid : 1 ), " scale= " . $scale , " rate= " . $rate , " maxfps= " . ZM_WEB_VIDEO_MAXFPS ) );
2004-03-04 23:05:54 +08:00
if ( canStreamNative () )
{
2005-12-08 19:10:44 +08:00
outputImageStream ( $stream_src , reScale ( $event [ 'Width' ], $scale ), reScale ( $event [ 'Height' ], $scale ), $event [ 'Name' ] );
2004-03-04 23:05:54 +08:00
}
else
{
2005-12-08 19:10:44 +08:00
outputHelperStream ( $stream_src , reScale ( $event [ 'Width' ], $scale ), reScale ( $event [ 'Height' ], $scale ) );
2004-03-04 23:05:54 +08:00
}
2003-07-11 17:27:56 +08:00
}
2004-03-04 23:05:54 +08:00
?>
</ td ></ tr >
< ? php
2006-01-12 23:41:39 +08:00
if ( isNetscape () )
{
?>
< tr >
< td >< div id = " Panel " >
< ? php
for ( $i = 0 ; $i < $panel_sections ; $i ++ )
{
2006-01-13 00:48:32 +08:00
$start_frame = 1 + ( int ) round (( $i * $event [ Frames ]) / $panel_sections );
2006-01-12 23:41:39 +08:00
if ( ! empty ( $fid ) && $start_frame < $fid )
{
$section_color = $panel_done_color ;
}
else
{
$section_color = $panel_init_color ;
}
$section_width = $panel_section_width ;
if ( $i == 0 || $i == ( $panel_sections - 1 ) )
$section_width -- ;
if ( $i )
{
$section_offset = ( $i * $panel_section_width ) - 1 ;
$divider = " border-left: solid 1px $panel_divider_color ; " ;
}
else
{
$section_offset = 0 ;
$divider = " " ;
}
$title = " + " . ( int ) round (( $i * $frame_data [ 'Duration' ]) / $panel_sections ) . " s " ;
?>
< div class = " Section " id = " PanelSection<?= $i ?> " title = " <?= $title ?> " style = " width: <?= $section_width ?>px; left: <?= $section_offset ?>px; background-color: <?= $section_color ?>;<?= $divider ?> " onClick = " window.location='<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&eid=<?= $event['Id'] ?>&fid=<?= $start_frame ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>&page=<?= $page ?>&rate=<?= $rate ?>&scale=<?= $scale ?>' " ></ div >
< ? php
}
?>
</ div ></ td >
</ tr >
< ? php
}
2004-01-08 19:45:57 +08:00
}
else
{
if ( $paged && ! empty ( $page ) )
2004-03-04 23:13:10 +08:00
{
$lo_frame_id = (( $page - 1 ) * $frames_per_page ) + 1 ;
$hi_frame_id = min ( $page * $frames_per_page , $event [ 'Frames' ] );
}
else
{
2004-03-05 18:31:54 +08:00
$lo_frame_id = 1 ;
$hi_frame_id = $event [ 'Frames' ];
2004-03-04 23:13:10 +08:00
}
2004-08-11 22:27:15 +08:00
$sql = " select * from Frames where EventId = ' $eid ' " ;
2004-03-04 23:13:10 +08:00
if ( $paged && ! empty ( $page ) )
$sql .= " and FrameId between $lo_frame_id and $hi_frame_id " ;
2004-03-05 18:31:54 +08:00
$sql .= " order by FrameId " ;
2004-01-08 19:45:57 +08:00
$result = mysql_query ( $sql );
if ( ! $result )
die ( mysql_error () );
2004-03-04 23:13:10 +08:00
$alarm_frames = array ();
while ( $row = mysql_fetch_assoc ( $result ) )
{
if ( $row [ 'Type' ] == 'Alarm' )
{
$alarm_frames [ $row [ 'FrameId' ]] = $row ;
}
}
2006-01-12 23:41:39 +08:00
mysql_free_result ( $result );
2003-07-11 17:27:56 +08:00
?>
2005-05-18 06:18:14 +08:00
< tr >< td >< table border = " 0 " cellpadding = " 0 " cellspacing = " 2 " align = " center " >
2003-07-11 17:27:56 +08:00
< tr >
< ? php
2004-01-08 19:45:57 +08:00
$count = 0 ;
2006-01-01 04:12:24 +08:00
$image_scaling = ZM_WEB_IMAGE_SCALING ;
$fraction = sprintf ( " %.2f " , 1 / $image_scaling );
2004-09-23 20:06:21 +08:00
$thumb_width = $event [ 'Width' ] / ZM_WEB_FRAMES_PER_LINE ;
$thumb_height = $event [ 'Height' ] / ZM_WEB_FRAMES_PER_LINE ;
2004-09-07 16:45:00 +08:00
$event_path = ZM_DIR_EVENTS . '/' . $event [ 'MonitorId' ] . '/' . $event [ 'Id' ];
2004-03-05 18:31:54 +08:00
for ( $frame_id = $lo_frame_id ; $frame_id <= $hi_frame_id ; $frame_id ++ )
2004-01-08 19:45:57 +08:00
{
2004-03-22 18:33:40 +08:00
$image_path = sprintf ( " %s/%0 " . ZM_EVENT_IMAGE_DIGITS . " d-capture.jpg " , $event_path , $frame_id );
2004-01-08 19:45:57 +08:00
$capt_image = $image_path ;
2006-01-01 04:12:24 +08:00
if ( $image_scaling == 1 || ! file_exists ( ZM_PATH_NETPBM . " /jpegtopnm " ) )
2003-07-11 17:27:56 +08:00
{
2004-01-08 19:45:57 +08:00
$anal_image = preg_replace ( " /capture/ " , " analyse " , $image_path );
2003-07-11 17:27:56 +08:00
2004-01-08 19:45:57 +08:00
if ( file_exists ( $anal_image ) && filesize ( $anal_image ) )
2003-07-11 17:27:56 +08:00
{
2004-01-08 19:45:57 +08:00
$thumb_image = $anal_image ;
2003-07-11 17:27:56 +08:00
}
else
{
2004-01-08 19:45:57 +08:00
$thumb_image = $capt_image ;
}
}
else
{
$thumb_image = preg_replace ( " /capture/ " , " thumb " , $capt_image );
2003-07-11 17:27:56 +08:00
2004-01-08 19:45:57 +08:00
if ( ! file_exists ( $thumb_image ) || ! filesize ( $thumb_image ) )
{
$anal_image = preg_replace ( " /capture/ " , " analyse " , $capt_image );
if ( file_exists ( $anal_image ) )
$command = ZM_PATH_NETPBM . " /jpegtopnm -dct fast $anal_image | " . ZM_PATH_NETPBM . " /pnmscalefixed $fraction | " . ZM_PATH_NETPBM . " /ppmtojpeg --dct=fast > $thumb_image " ;
else
$command = ZM_PATH_NETPBM . " /jpegtopnm -dct fast $capt_image | " . ZM_PATH_NETPBM . " /pnmscalefixed $fraction | " . ZM_PATH_NETPBM . " /ppmtojpeg --dct=fast > $thumb_image " ;
#exec( escapeshellcmd( $command ) );
exec ( $command );
2003-07-11 17:27:56 +08:00
}
2004-01-08 19:45:57 +08:00
}
2004-03-04 23:13:10 +08:00
$alarm_frame = $alarm_frames [ $frame_id ];
$img_class = $alarm_frame ? " alarm " : " normal " ;
2003-07-11 17:27:56 +08:00
?>
2006-01-01 04:12:24 +08:00
< td align = " center " width = " 88 " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=frame&eid=<?= $eid ?>&fid=<?= $frame_id ?>&scale=<?= $scale ?>', 'zmImage', <?= reScale( $event['Width'] , $scale )+ $jws['image'] ['w'] ?>, <?= reScale( $event['Height'] , $scale )+ $jws['image'] ['h'] ?> ); " >< img src = " <?= $thumb_image ?> " width = " <?= $thumb_width ?> " height = " <?= $thumb_height ?> " class = " <?= $img_class ?> " alt = " <?= $frame_id ?>/<?= $alarm_frame ? $alarm_frame['Score'] :0 ?> " ></ a ></ td >
2003-07-11 17:27:56 +08:00
< ? php
2004-01-08 19:45:57 +08:00
flush ();
2006-01-01 04:12:24 +08:00
if ( ! ( ++ $count % $frames_per_line ) )
2004-01-08 19:45:57 +08:00
{
2003-07-11 17:27:56 +08:00
?>
</ tr >
< tr >
< ? php
}
2004-01-08 19:45:57 +08:00
}
2003-07-11 17:27:56 +08:00
?>
</ tr >
</ table ></ td ></ tr >
< ? php
2004-01-08 19:45:57 +08:00
}
2003-07-11 17:27:56 +08:00
?>
< tr >
2005-05-18 06:18:14 +08:00
< td >< table width = " 100% " cellpadding = " 0 " cellspacing = " 0 " border = " 0 " >< tr >
2004-09-24 06:21:05 +08:00
< td width = " 20% " align = " center " class = " text " >< ? php if ( $prev_event ) { ?> <a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&eid=<?= $prev_event['Id'] ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>&page=<?= $page ?>&rate=<?= $rate ?>&scale=<?= $scale ?>"><?= $zmSlangPrev ?></a><?php } else { ?> <?php } ?></td>
< td width = " 20% " align = " center " class = " text " >< ? php if ( canEdit ( 'Events' ) && $prev_event ) { ?> <a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&eid=<?= $prev_event['Id'] ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>&action=delete&mark_eid=<?= $eid ?>&page=<?= $page ?>&rate=<?= $rate ?>&scale=<?= $scale ?>"><?= $zmSlangDeleteAndPrev ?></a><?php } else { ?> <?php } ?></td>
2005-05-20 00:20:56 +08:00
< td width = " 20% " align = " center " class = " text " >< ? php if ( $mode == " stream " ) { if ( $frame_data ) { ?> <a href="javascript: window.clearTimeout( timeout_id );"><?= $zmSlangStop ?></a><?php } elseif ( $next_event ) { ?><a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&eid=<?= $eid ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>&page=<?= $page ?>&rate=<?= $rate ?>&scale=<?= $scale ?>&play=1"><?= $zmSlangPlayAll ?></a><?php } else { ?> <?php } } else { ?> <?php } ?></td>
2004-09-24 06:21:05 +08:00
< td width = " 20% " align = " center " class = " text " >< ? php if ( canEdit ( 'Events' ) && $next_event ) { ?> <a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&eid=<?= $next_event['Id'] ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>&action=delete&mark_eid=<?= $eid ?>&page=<?= $page ?>&rate=<?= $rate ?>&scale=<?= $scale ?>"><?= $zmSlangDeleteAndNext ?></a><?php } else { ?> <?php } ?></td>
< td width = " 20% " align = " center " class = " text " >< ? php if ( $next_event ) { ?> <a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&eid=<?= $next_event['Id'] ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>&page=<?= $page ?>&rate=<?= $rate ?>&scale=<?= $scale ?>"><?= $zmSlangNext ?></a><?php } else { ?> <?php } ?></td>
2003-07-11 17:27:56 +08:00
</ tr ></ table ></ td >
</ tr >
</ table >
2006-01-13 00:48:32 +08:00
< ? php
if ( $mode == " stream " )
{
?>
< script type = " text/javascript " >
< ? php
if ( $play && $next_event )
{
?>
var timeout_id = window . setTimeout ( " window.location.replace( '<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&eid=<?= $next_event['Id'] ?><?= $filter_query ?><?= $sort_query ?>&limit=<?= $limit ?>&page=<?= $page ?>&rate=<?= $rate ?>&scale=<?= $scale ?>&play=1' ); " , < ? = ( $frame_data [ 'RealDuration' ] + 1 ) * 1000 ?> );
< ? php
}
$start_section = 0 ;
if ( ! empty ( $fid ) )
{
$start_section = ( int ) floor (( $fid * $panel_sections ) / ( $event [ 'Frames' ] + 1 ));
}
?>
window . setTimeout ( " incrementPanel( <?= $start_section ?> ) " , < ? = 2000 + $panel_timeout ?> );
function incrementPanel ( section )
{
document . getElementById ( 'PanelSection' + section ) . style . backgroundColor = '<?= $panel_done_color ?>' ;
section ++ ;
if ( section < < ? = $panel_sections ?> )
{
window . setTimeout ( " incrementPanel( " + section + " ) " , < ? = $panel_timeout ?> );
}
}
</ script >
< ? php
}
?>
2003-07-11 17:27:56 +08:00
</ body >
</ html >
2006-01-12 23:41:39 +08:00
< ? php
ob_end_flush ();
?>