2003-07-11 17:27:56 +08:00
< ? php
2004-01-08 19:45:57 +08:00
//
// ZoneMinder web event view file, $Date$, $Revision$
2006-01-17 19:29:45 +08:00
// Copyright (C) 2003, 2004, 2005, 2006 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' ) )
{
2006-05-23 05:36:09 +08:00
$view = " error " ;
return ;
2004-01-08 19:45:57 +08:00
}
if ( ! isset ( $mode ) )
{
2006-05-23 05:36:09 +08:00
if ( ZM_WEB_USE_STREAMS && canStream () )
$mode = " stream " ;
else
$mode = " still " ;
2004-01-08 19:45:57 +08:00
}
2003-07-11 17:27:56 +08:00
2004-03-10 01:07:09 +08:00
if ( $user [ 'MonitorIds' ] )
{
2006-05-23 05:36:09 +08:00
$mid_sql = " and MonitorId in ( " . join ( " , " , preg_split ( '/["\'\s]*,["\'\s]*/' , $user [ 'MonitorIds' ] ) ) . " ) " ;
2004-03-10 01:07:09 +08:00
}
else
{
2006-05-23 05:36:09 +08:00
$mid_sql = '' ;
2004-03-10 01:07:09 +08:00
}
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 )
2006-05-23 05:36:09 +08:00
die ( mysql_error () );
2004-01-08 19:45:57 +08:00
$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 )
2006-05-23 05:36:09 +08:00
die ( mysql_error () );
2004-03-10 22:23:22 +08:00
while ( $row = mysql_fetch_assoc ( $result ) )
{
2006-05-23 05:36:09 +08:00
if ( $row [ 'Id' ] == $eid )
{
$prev_event = mysql_fetch_assoc ( $result );
break ;
}
2004-03-10 22:23:22 +08:00
}
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 )
2006-05-23 05:36:09 +08:00
die ( mysql_error () );
2004-03-10 22:23:22 +08:00
while ( $row = mysql_fetch_assoc ( $result ) )
{
2006-05-23 05:36:09 +08:00
if ( $row [ 'Id' ] == $eid )
{
$next_event = mysql_fetch_assoc ( $result );
break ;
}
2004-03-10 22:23:22 +08:00
}
2006-01-12 23:41:39 +08:00
mysql_free_result ( $result );
2004-01-08 19:45:57 +08:00
if ( ! isset ( $rate ) )
2006-05-23 05:36:09 +08:00
$rate = reScale ( RATE_BASE , $event [ 'DefaultRate' ], ZM_WEB_DEFAULT_RATE );
2004-01-08 19:45:57 +08:00
if ( ! isset ( $scale ) )
2006-05-23 05:36:09 +08:00
$scale = reScale ( SCALE_BASE , $event [ 'DefaultScale' ], ZM_WEB_DEFAULT_SCALE );
2006-01-18 01:07:13 +08:00
if ( $mode == " still " && $scale < SCALE_BASE )
2006-05-23 05:36:09 +08:00
$scale = SCALE_BASE ;
2003-07-11 17:27:56 +08:00
2006-01-18 01:07:13 +08:00
$frames_per_line = ZM_WEB_FRAMES_PER_LINE ;
$frames_per_page = $frames_per_line * ZM_WEB_FRAME_LINES ;
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 " )
{
2006-05-23 05:36:09 +08:00
$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_BASE ) / $rate ;
2006-01-12 23:41:39 +08:00
2006-05-23 05:36:09 +08:00
$panel_init_color = '#eeeeee' ;
$panel_done_color = '#aaaaaa' ;
$panel_border_color = '#666666' ;
$panel_divider_color = '#999999' ;
2006-01-12 23:41:39 +08:00
2006-05-23 05:36:09 +08:00
$panel_sections = 40 ;
$panel_section_width = ( int ) ceil ( reScale ( $event [ 'Width' ], $scale ) / $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 );
2006-01-18 05:11:49 +08:00
2006-05-23 05:36:09 +08:00
if ( ! isset ( $play ) )
$play = false ;
2006-01-12 23:41:39 +08:00
}
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 ()
{
2006-05-23 05:36:09 +08:00
window . location . reload ( true );
2003-07-11 17:27:56 +08:00
}
function closeWindow ()
{
2006-05-23 05:36:09 +08:00
window . close ();
2003-07-11 17:27:56 +08:00
}
function newWindow ( Url , Name , Width , Height )
{
2006-05-23 05:36:09 +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-18 05:22:05 +08:00
if ( $mode == " stream " && ZM_WEB_SHOW_PROGRESS && isNetscape () )
2004-09-24 06:21:05 +08:00
{
2006-01-12 23:41:39 +08:00
?>
function incrementPanel ( section )
{
2006-05-23 05:36:09 +08:00
document . getElementById ( 'PanelSection' + section ) . style . backgroundColor = '<?= $panel_done_color ?>' ;
section ++ ;
if ( section < < ? = $panel_sections ?> )
{
window . setTimeout ( " incrementPanel( " + section + " ) " , < ? = $panel_timeout ?> );
}
2006-01-12 23:41:39 +08:00
}
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 {
2006-05-23 05:36:09 +08:00
position : relative ;
text - align : center ;
border : 1 px solid < ? = $panel_border_color ?> ;
height : 15 px ;
width : < ? = $panel_width ?> px;
padding : 0 px ;
margin : auto ;
2006-01-12 23:41:39 +08:00
}
#Panel div.Section {
2006-05-23 05:36:09 +08:00
position : absolute ;
height : 15 px ;
2006-01-12 23:41:39 +08:00
}
-->
</ style >
< ? php
}
?>
2003-07-11 17:27:56 +08:00
</ head >
2003-12-16 22:56:36 +08:00
< body scroll = " auto " >
2006-05-23 05:36:09 +08:00
< table border = " 0 " cellspacing = " 0 " cellpadding = " 3 " width = " 100% " >
< tr >
< td >< table border = " 0 " cellspacing = " 1 " cellpadding = " 2 " width = " 100% " style = " background: #666699 " >
< tr style = " background: #ffffff " >
< td class = " text " align = " center " >< span title = " <?= $zmSlangId ?> " >< ? = $event [ 'Id' ] ?> </span></td>
2006-05-24 21:42:14 +08:00
< td class = " text " align = " center " >< span title = " <?= $event['Notes'] ?htmlentities( $event['Notes'] ): $zmSlangAttrCause ?> " >< ? = htmlentities ( $event [ 'Cause' ]) ?> </span></td>
2006-05-23 05:36:09 +08:00
< td class = " text " align = " center " >< span title = " <?= $zmSlangTime ?> " >< ? = strftime ( STRF_FMT_DATETIME_SHORT , strtotime ( $event [ 'StartTime' ] ) ) ?> </span></td>
< td class = " text " align = " center " >< span title = " <?= $zmSlangDuration ?> " >< ? = $event [ 'Length' ] . " s " ?> </span></td>
< td class = " text " align = " center " >< span title = " <?= $zmSlangAttrFrames . " / " . $zmSlangAttrAlarmFrames ?> " >< ? = $event [ 'Frames' ] ?> /<?= $event['AlarmFrames'] ?></span></td>
< td class = " text " align = " center " >< span title = " <?= $zmSlangAttrTotalScore . " / " . $zmSlangAttrAvgScore . " / " . $zmSlangAttrMaxScore ?> " >< ? = $event [ 'TotScore' ] ?> /<?= $event['AvgScore'] ?>/<?= $event['MaxScore'] ?></span></td>
</ tr >
</ table ></ td >
</ tr >
2003-07-11 17:27:56 +08:00
< tr >
2005-05-18 06:18:14 +08:00
< td >< table border = " 0 " cellspacing = " 0 " cellpadding = " 2 " width = " 100% " >
< tr >
2006-05-23 05:36:09 +08:00
< td align = " left " class = " text " >< form name = " rename_form " method = " get " action = " <?= $PHP_SELF ?> " >
2003-07-11 17:27:56 +08:00
< 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 ) { ?>
2006-05-23 05:36:09 +08:00
< td align = " center " class = " text " >< form name = " learn_form " method = " get " action = " <?= $PHP_SELF ?> " >
2003-07-11 17:27:56 +08:00
< 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 } ?>
2006-05-23 05:36:09 +08:00
< td align = " right " class = " text " >< 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();" ); ?>
2006-05-23 05:36:09 +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
2006-05-23 05:36:09 +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
2006-05-23 05:36:09 +08:00
if ( $page < 0 )
$page = 1 ;
if ( $page > $pages )
$page = $pages ;
2003-11-14 18:28:17 +08:00
2006-05-23 05:36:09 +08:00
if ( $page > 1 )
{
if ( false && $page > 2 )
{
2005-11-11 20:08:38 +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=1 " >& lt ; & lt ; </ a >& nbsp ;
2005-11-11 20:08:38 +08:00
< ? php
2006-05-23 05:36:09 +08:00
}
2005-11-11 20:08:38 +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=<?= $page - 1 ?> " >& lt ; </ a >& nbsp ;
2005-11-11 20:08:38 +08:00
< ? php
2006-05-23 05:36:09 +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 ++ )
{
$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
2006-05-23 05:36:09 +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
2006-05-23 05:36:09 +08:00
}
}
2003-11-14 18:28:17 +08:00
?>
-& nbsp ; < ? = $page ?> -
< ? php
2006-05-23 05:36:09 +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 ++ )
{
$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
2006-05-23 05:36:09 +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-05-23 05:36:09 +08:00
}
2005-11-11 20:08:38 +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=<?= $page + 1 ?> " >& gt ; </ a >
2005-11-11 20:08:38 +08:00
< ? php
2006-05-23 05:36:09 +08:00
if ( false && $page < ( $pages - 1 ) )
{
2005-11-11 20:08:38 +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=<?= $pages ?> " >& gt ; & gt ; </ a >
2003-11-14 18:28:17 +08:00
< ? php
2006-05-23 05:36:09 +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
2006-05-23 05:36:09 +08:00
if ( ZM_STREAM_METHOD == 'mpeg' && ZM_MPEG_REPLAY_FORMAT )
{
2007-08-30 02:11:09 +08:00
$stream_src = getStreamSrc ( array ( " source=event " , " 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_MPEG_REPLAY_FORMAT ) );
2006-05-23 05:36:09 +08:00
outputVideoStream ( $stream_src , reScale ( $event [ 'Width' ], $scale ), reScale ( $event [ 'Height' ], $scale ), $event [ 'Name' ], ZM_MPEG_REPLAY_FORMAT );
}
else
{
2007-08-30 02:11:09 +08:00
$stream_src = getStreamSrc ( array ( " source=event " , " mode=jpeg " , " event= " . $eid , " frame= " . ( ! empty ( $fid ) ? $fid : 1 ), " scale= " . $scale , " rate= " . $rate , " maxfps= " . ZM_WEB_VIDEO_MAXFPS ) );
2006-05-23 05:36:09 +08:00
if ( canStreamNative () )
{
outputImageStream ( $stream_src , reScale ( $event [ 'Width' ], $scale ), reScale ( $event [ 'Height' ], $scale ), $event [ 'Name' ] );
}
else
{
outputHelperStream ( $stream_src , reScale ( $event [ 'Width' ], $scale ), reScale ( $event [ 'Height' ], $scale ) );
}
}
2004-03-04 23:05:54 +08:00
?>
</ td ></ tr >
< ? php
2006-05-23 05:36:09 +08:00
if ( isNetscape () )
{
2006-01-12 23:41:39 +08:00
?>
< tr >
< td >< div id = " Panel " >
< ? php
2006-05-23 05:36:09 +08:00
for ( $i = 0 ; $i < $panel_sections ; $i ++ )
{
$start_frame = 1 + ( int ) round (( $i * $event [ 'Frames' ]) / $panel_sections );
if ( ZM_WEB_SHOW_PROGRESS && ! 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 " ;
2006-01-12 23:41:39 +08:00
?>
< 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
2006-05-23 05:36:09 +08:00
}
2006-01-12 23:41:39 +08:00
?>
</ div ></ td >
</ tr >
< ? php
2006-05-23 05:36:09 +08:00
}
2004-01-08 19:45:57 +08:00
}
else
{
2006-05-23 05:36:09 +08:00
if ( $paged && ! empty ( $page ) )
{
2006-11-17 03:06:31 +08:00
$lo_frame_id = (( $page - 1 ) * $frames_per_page ) + 1 ;
2006-05-23 05:36:09 +08:00
$hi_frame_id = min ( $page * $frames_per_page , $event [ 'Frames' ] );
}
else
{
2006-11-17 03:06:31 +08:00
$lo_frame_id = 1 ;
2006-05-23 05:36:09 +08:00
$hi_frame_id = $event [ 'Frames' ];
}
$sql = " select * from Frames where EventId = ' $eid ' " ;
$sql .= " order by FrameId " ;
if ( $paged && ! empty ( $page ) )
2006-05-24 21:42:14 +08:00
$sql .= " limit $lo_frame_id , " . ( $hi_frame_id - $lo_frame_id );
2006-05-23 05:36:09 +08:00
$result = mysql_query ( $sql );
if ( ! $result )
die ( mysql_error () );
$frames = array ();
while ( $frame = mysql_fetch_assoc ( $result ) )
{
2006-11-17 03:06:31 +08:00
$frames [ $frame [ 'FrameId' ]] = $frame ;
2006-05-23 05:36:09 +08:00
}
mysql_free_result ( $result );
2003-07-11 17:27:56 +08:00
?>
2006-01-18 05:11:49 +08:00
< tr >< td >< div style = " text-align: center " >
2003-07-11 17:27:56 +08:00
< ? php
2006-05-23 05:36:09 +08:00
$count = 0 ;
2004-01-08 19:45:57 +08:00
2006-05-23 05:36:09 +08:00
$thumb_width = ( int ) round ( $event [ 'Width' ] / ZM_WEB_FRAMES_PER_LINE );
$thumb_height = ( int ) round ( $event [ 'Height' ] / ZM_WEB_FRAMES_PER_LINE );
$thumb_scale = ( int ) round ( SCALE_BASE / ZM_WEB_FRAMES_PER_LINE );
2003-07-11 17:27:56 +08:00
2006-11-17 03:06:31 +08:00
for ( $i = $lo_frame_id ; $i <= $hi_frame_id ; $i ++ )
2006-05-23 05:36:09 +08:00
{
2006-11-17 03:06:31 +08:00
if ( ! ( $frame = $frames [ $i ]) )
{
$frame = array ( 'FrameId' => $i , 'Type' => 'Normal' );
}
2006-05-23 05:36:09 +08:00
$image_data = getImageSrc ( $event , $frame , $thumb_scale );
2006-01-18 01:07:13 +08:00
?>
2006-03-31 18:11:50 +08:00
< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=frame&eid=<?= $eid ?>&fid=<?= $frame['FrameId'] ?>&scale=<?= $scale ?>', 'zmImage', <?= reScale( $event['Width'] , $scale )+ $jws['image'] ['w'] ?>, <?= reScale( $event['Height'] , $scale )+ $jws['image'] ['h'] ?> ); " >< img src = " <?= $image_data['thumbPath'] ?> " width = " <?= $thumb_width ?> " height = " <?= $thumb_height ?> " class = " <?= $image_data['imageClass'] ?> " alt = " <?= $frame['FrameId'] ?>/<?= $frame['Type'] =='alarm'? $frame['Score'] :0 ?> " ></ a >
2003-07-11 17:27:56 +08:00
< ? php
2006-05-23 05:36:09 +08:00
}
2003-07-11 17:27:56 +08:00
?>
2006-01-18 05:11:49 +08:00
</ div ></ td ></ tr >
2003-07-11 17:27:56 +08:00
< ? 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>
2006-04-05 23:36:43 +08:00
< td width = " 20% " align = " center " class = " text " >< ? php if ( $mode == " stream " ) { if ( $play && $next_event ) { ?> <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
2006-05-23 05:36:09 +08:00
if ( $play && $next_event )
{
2006-01-13 00:48:32 +08:00
?>
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
2006-05-23 05:36:09 +08:00
}
$start_section = 0 ;
if ( ! empty ( $fid ) )
{
$start_section = ( int ) floor ((( $fid - 1 ) * $panel_sections ) / ( $event [ 'Frames' ] + 1 ));
}
if ( ZM_WEB_SHOW_PROGRESS && isNetscape () )
{
2006-01-13 00:48:32 +08:00
?>
2006-01-17 19:29:45 +08:00
window . setTimeout ( " incrementPanel( <?= $start_section ?> ) " , < ? = $panel_timeout ?> );
2006-01-14 21:38:46 +08:00
< ? php
2006-05-23 05:36:09 +08:00
}
2006-01-14 21:38:46 +08:00
?>
2006-01-13 00:48:32 +08:00
</ script >
< ? php
}
?>
2003-07-11 17:27:56 +08:00
</ body >
</ html >
2006-01-12 23:41:39 +08:00
< ? php
ob_end_flush ();
?>