2002-10-11 17:45:06 +08:00
< ? php
//
2002-12-10 21:23:22 +08:00
// ZoneMinder HTML interface file, $Date$, $Revision$
2003-01-12 02:22:27 +08:00
// Copyright (C) 2003 Philip Coombes
2002-10-11 17:45:06 +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.
//
if ( ! $bandwidth )
{
$new_bandwidth = " low " ;
}
if ( $new_bandwidth )
{
$bandwidth = $new_bandwidth ;
setcookie ( " bandwidth " , $new_bandwidth , time () + 3600 * 24 * 30 * 12 * 10 );
}
2003-03-26 20:40:23 +08:00
require_once ( 'zm_config.php' );
require_once ( 'zm_db.php' );
require_once ( 'zm_funcs.php' );
require_once ( 'zm_actions.php' );
2002-10-11 17:45:06 +08:00
if ( ! $view )
{
$view = " console " ;
}
2002-10-28 04:25:27 +08:00
switch ( $view )
2002-10-11 17:45:06 +08:00
{
2002-10-28 04:25:27 +08:00
case " console " :
2002-10-11 17:45:06 +08:00
{
2002-12-24 19:56:34 +08:00
$running = daemonCheck ();
$status = $running ? " Running " : " Stopped " ;
$new_status = $running ? " stop " : " start " ;
if ( $stop )
{
2003-01-14 21:07:57 +08:00
packageControl ( 'stop' );
2002-12-24 19:56:34 +08:00
}
2003-01-07 18:44:25 +08:00
if ( $start )
{
2003-01-14 21:07:57 +08:00
packageControl ( 'start' );
2003-01-07 18:44:25 +08:00
}
2002-12-24 19:56:34 +08:00
header ( " Refresh: " . (( $start || $stop ) ? 1 : REFRESH_MAIN ) . " ; URL=' $PHP_SELF ' " );
2002-10-28 04:25:27 +08:00
header ( " Expires: Mon, 26 Jul 1997 05:00:00 GMT " ); // Date in the past
header ( " Last-Modified: " . gmdate ( " D, d M Y H:i:s " ) . " GMT " ); // always modified
header ( " Cache-Control: no-store, no-cache, must-revalidate " ); // HTTP/1.1
header ( " Cache-Control: post-check=0, pre-check=0 " , false );
header ( " Pragma: no-cache " ); // HTTP/1.0
2002-10-11 17:45:06 +08:00
2002-10-30 20:40:27 +08:00
$db_now = strftime ( " %Y-%m-%d %H:%M:%S " );
2003-03-26 19:41:22 +08:00
$sql = " select M.*, count(E.Id) as EventCount, count(if(E.Archived,1,NULL)) as ArchEventCount, count(if(E.StartTime>' $db_now ' - INTERVAL 1 HOUR && E.Archived = 0,1,NULL)) as HourEventCount, count(if(E.StartTime>' $db_now ' - INTERVAL 1 DAY && E.Archived = 0,1,NULL)) as DayEventCount, count(if(E.StartTime>' $db_now ' - INTERVAL 7 DAY && E.Archived = 0,1,NULL)) as WeekEventCount, count(if(E.StartTime>' $db_now ' - INTERVAL 1 MONTH && E.Archived = 0,1,NULL)) as MonthEventCount from Monitors as M left join Events as E on E.MonitorId = M.Id group by M.Id order by M.Id " ;
2002-10-28 04:25:27 +08:00
$result = mysql_query ( $sql );
if ( ! $result )
echo mysql_error ();
$monitors = array ();
$max_width = 0 ;
$max_height = 0 ;
$cycle_count = 0 ;
while ( $row = mysql_fetch_assoc ( $result ) )
2002-10-11 17:45:06 +08:00
{
2003-03-26 19:41:22 +08:00
$row [ 'zmc' ] = zmcCheck ( $row );
2002-12-24 19:56:34 +08:00
$row [ 'zma' ] = zmaCheck ( $row );
2003-04-13 20:20:00 +08:00
//$sql = "select count(Id) as ZoneCount, count(if(Type='Active',1,NULL)) as ActZoneCount, count(if(Type='Inclusive',1,NULL)) as IncZoneCount, count(if(Type='Exclusive',1,NULL)) as ExcZoneCount, count(if(Type='Inactive',1,NULL)) as InactZoneCount from Zones where MonitorId = '$row[Id]'";
$sql = " select count(Id) as ZoneCount from Zones where MonitorId = ' $row[Id] ' " ;
2002-10-28 04:25:27 +08:00
$result2 = mysql_query ( $sql );
if ( ! $result2 )
echo mysql_error ();
$row2 = mysql_fetch_assoc ( $result2 );
$monitors [] = array_merge ( $row , $row2 );
2002-12-24 19:56:34 +08:00
if ( $row [ 'Function' ] != 'None' )
2002-10-28 04:25:27 +08:00
{
2002-12-24 19:56:34 +08:00
$cycle_count ++ ;
2003-03-24 17:50:54 +08:00
if ( $max_width < $row [ Width ] ) $max_width = $row [ Width ];
if ( $max_height < $row [ Height ] ) $max_height = $row [ Height ];
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
}
2003-03-24 17:59:41 +08:00
$montage_rows = intval ( ceil ( $cycle_count / ZM_WEB_MONTAGE_MAX_COLS ));
2003-03-24 17:50:54 +08:00
$montage_cols = $cycle_count >= ZM_WEB_MONTAGE_MAX_COLS ? ZM_WEB_MONTAGE_MAX_COLS : $cycle_count ;
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
< title > ZM - Console </ title >
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
2003-01-14 00:39:00 +08:00
window . resizeTo ( < ? = $jws [ 'console' ][ 'w' ] ?> , <?= $jws['console']['h'] ?> );
2002-10-22 21:56:37 +08:00
function newWindow ( Url , Name , Width , Height )
{
var Name = window . open ( Url , Name , " resizable,scrollbars,width= " + Width + " ,height= " + Height );
2002-10-11 17:45:06 +08:00
}
2002-10-30 06:03:12 +08:00
function configureButton ( form , name )
{
var checked = false ;
for ( var i = 0 ; i < form . elements . length ; i ++ )
{
if ( form . elements [ i ] . name . indexOf ( name ) == 0 )
{
if ( form . elements [ i ] . checked )
{
checked = true ;
break ;
}
}
}
form . delete_btn . disabled = ! checked ;
}
2002-12-24 19:56:34 +08:00
function confirmStatus ( new_status )
{
return ( confirm ( 'Are you sure you wish to ' + new_status + ' all processes?' ) );
}
2002-10-11 17:45:06 +08:00
</ script >
</ head >
< body >
< table align = " center " border = " 0 " cellspacing = " 2 " cellpadding = " 2 " width = " 96% " >
< tr >
2003-01-14 00:39:00 +08:00
< td class = " smallhead " align = " left " >< ? = date ( " D jS M, g:ia " ) ?> </td>
2003-01-31 23:44:02 +08:00
< td class = " bighead " align = " center " >< strong > ZoneMinder Console - < ? = $status ?> (<a href="javascript: if ( confirmStatus( '<?= $new_status ?>' ) ) location='<?= $PHP_SELF ?>?<?= $new_status ?>=1';"><?= $new_status ?></a>) - v<?= ZM_VERSION ?></strong></td>
2003-01-14 21:45:56 +08:00
< ? php
$uptime = shell_exec ( 'uptime' );
$load = '' ;
preg_match ( '/load average: ([\d.]+)/' , $uptime , $matches );
?>
< td class = " smallhead " align = " right " > Server Load : < ? = $matches [ 1 ] ?> </td>
2002-10-30 06:03:12 +08:00
</ tr >
< tr >
2003-01-14 21:45:56 +08:00
< td class = " smallhead " align = " left " >
2003-03-21 20:22:56 +08:00
< ? php
if ( $cycle_count > 1 )
{
?>
< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=cycle', 'zmCycle', <?= $max_width + $jws['cycle'] ['w'] ?>, <?= $max_height + $jws['cycle'] ['h'] ?> ); " >< ? = count ( $monitors ) ?> Monitor<?= count($monitors)==1?'':'s' ?></a> (<a href="javascript: newWindow( '<?= $PHP_SELF ?>?view=montage', 'zmMontage', <?= ($montage_cols*$max_width)+$jws['montage']['w'] ?>, <?= ($montage_rows*(40+$max_height))+$jws['montage']['h'] ?> );">Montage</a>)
< ? php
}
else
{
?>
2003-01-14 21:45:56 +08:00
< ? = count ( $monitors ) ?> Monitor<?= count($monitors)==1?'':'s' ?>
2003-03-21 20:22:56 +08:00
< ? php
}
?>
2003-01-14 21:45:56 +08:00
</ td >
2003-01-14 00:39:00 +08:00
< td class = " smallhead " align = " center " > Configured for < strong >< ? = $bandwidth ?> </strong> bandwidth (change to
2002-10-28 06:48:24 +08:00
< ? php
$bw_array = array ( " high " => 1 , " medium " => 1 , " low " => 1 );
unset ( $bw_array [ $bandwidth ] );
$bw_keys = array_keys ( $bw_array );
?>
2003-01-14 00:39:00 +08:00
< a href = " <?= $PHP_SELF ?>?new_bandwidth=<?= $bw_keys[0] ?> " >< ? = $bw_keys [ 0 ] ?> </a>,
< a href = " <?= $PHP_SELF ?>?new_bandwidth=<?= $bw_keys[1] ?> " >< ? = $bw_keys [ 1 ] ?> </a>)
2003-01-31 23:44:02 +08:00
< td class = " smallhead " align = " right " >< a href = " mailto:bugs@zoneminder.com?subject=ZoneMinder Bug (v<?= ZM_VERSION ?>) " > Report Bug </ a ></ td >
2002-10-11 17:45:06 +08:00
</ tr >
</ table >
< table align = " center " border = " 0 " cellspacing = " 2 " cellpadding = " 2 " width = " 96% " >
2003-01-14 00:39:00 +08:00
< form name = " monitor_form " method = " get " action = " <?= $PHP_SELF ?> " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
2002-10-11 17:45:06 +08:00
< input type = " hidden " name = " action " value = " delete " >
< tr >< td align = " left " class = " smallhead " > Id </ td >
< td align = " left " class = " smallhead " > Name </ td >
< td align = " left " class = " smallhead " > Function </ td >
2003-03-26 19:41:22 +08:00
< td align = " left " class = " smallhead " > Source </ td >
2002-10-11 17:45:06 +08:00
<!--< td align = " left " class = " smallhead " > Dimensions </ td >-->
< td align = " right " class = " smallhead " > Events </ td >
< td align = " right " class = " smallhead " > Hour </ td >
< td align = " right " class = " smallhead " > Day </ td >
< td align = " right " class = " smallhead " > Week </ td >
< td align = " right " class = " smallhead " > Month </ td >
< td align = " right " class = " smallhead " > Archive </ td >
< td align = " right " class = " smallhead " > Zones </ td >
2002-10-30 06:03:12 +08:00
< td align = " center " class = " smallhead " > Mark </ td >
2002-10-11 17:45:06 +08:00
</ tr >
< ? php
2002-10-28 04:25:27 +08:00
$event_count = 0 ;
$hour_event_count = 0 ;
$day_event_count = 0 ;
$week_event_count = 0 ;
$month_event_count = 0 ;
$arch_event_count = 0 ;
$zone_count = 0 ;
foreach ( $monitors as $monitor )
{
$event_count += $monitor [ EventCount ];
$hour_event_count += $monitor [ HourEventCount ];
$day_event_count += $monitor [ DayEventCount ];
$week_event_count += $monitor [ WeekEventCount ];
$month_event_count += $monitor [ MonthEventCount ];
$arch_event_count += $monitor [ ArchEventCount ];
$zone_count += $monitor [ ZoneCount ];
2002-10-11 17:45:06 +08:00
?>
< tr >
2003-01-14 00:39:00 +08:00
< td align = " left " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=monitor&mid=<?= $monitor[Id] ?>', 'zmMonitor', <?= $jws['monitor'] ['w'] ?>, <?= $jws['monitor'] ['h'] ?> ); " >< ? = $monitor [ Id ] ?> .</a></td>
2002-12-24 19:56:34 +08:00
< ? php
2003-03-26 19:41:22 +08:00
if ( ! $monitor [ zmc ] )
2002-12-24 19:56:34 +08:00
{
2003-03-26 19:41:22 +08:00
$dclass = " redtext " ;
2002-12-24 19:56:34 +08:00
}
else
{
2003-03-26 19:41:22 +08:00
if ( ! $monitor [ zma ] )
{
$dclass = " oratext " ;
}
else
{
$dclass = " gretext " ;
}
}
if ( $monitor [ 'Function' ] == 'Active' )
{
$fclass = " gretext " ;
}
elseif ( $monitor [ 'Function' ] == 'Passive' )
{
$fclass = " oratext " ;
}
elseif ( $monitor [ 'Function' ] == 'X10' )
{
$fclass = " blutext " ;
}
else
{
$fclass = " redtext " ;
2002-12-24 19:56:34 +08:00
}
?>
2003-01-14 00:39:00 +08:00
< td align = " left " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=watch&mid=<?= $monitor[Id] ?>', 'zmWatch<?= $monitor[Name] ?>', <?= $monitor[Width] + $jws['watch'] ['w'] ?>, <?= $monitor[Height] + $jws['watch'] ['h'] ?> ); " >< ? = $monitor [ Name ] ?> </a></td>
< td align = " left " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=function&mid=<?= $monitor[Id] ?>', 'zmFunction', <?= $jws['function'] ['w'] ?>, <?= $jws['function'] ['h'] ?> ); " >< span class = " <?= $fclass ?> " >< ? = $monitor [ 'Function' ] ?> </span></a></td>
2003-03-26 19:41:22 +08:00
< ? php if ( $monitor [ Type ] == " Local " ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " left " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=monitor&mid=<?= $monitor[Id] ?>', 'zmMonitor', <?= $jws['monitor'] ['w'] ?>, <?= $jws['monitor'] ['h'] ?> ); " >< span class = " <?= $dclass ?> " >/ dev / video < ? = $monitor [ Device ] ?> (<?= $monitor[Channel] ?>)</span></a></td>
2003-03-26 19:41:22 +08:00
< ? php } else { ?>
< td align = " left " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=monitor&mid=<?= $monitor[Id] ?>', 'zmMonitor', <?= $jws['monitor'] ['w'] ?>, <?= $jws['monitor'] ['h'] ?> ); " >< span class = " <?= $dclass ?> " >< ? = $monitor [ Host ] ?> </span></a></td>
< ? php } ?>
2003-01-14 00:39:00 +08:00
< td align = " right " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=events&mid=<?= $monitor[Id] ?>&filter=1', 'zmEvents<?= $monitor[Name] ?>', <?= $jws['events'] ['w'] ?>, <?= $jws['events'] ['h'] ?> ); " >< ? = $monitor [ EventCount ] ?> </a></td>
< td align = " right " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=events&mid=<?= $monitor[Id] ?>&filter=1&trms=2&attr1=Archived&val1=0&cnj2=and&attr2=DateTime&op2=%3e%3d&val2=last+hour', 'zmEvents<?= $monitor[Name] ?>', <?= $jws['events'] ['w'] ?>, <?= $jws['events'] ['h'] ?> ); " >< ? = $monitor [ HourEventCount ] ?> </a></td>
< td align = " right " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=events&mid=<?= $monitor[Id] ?>&filter=1&trms=2&attr1=Archived&val1=0&cnj2=and&attr2=DateTime&op2=%3e%3d&val2=last+day', 'zmEvents<?= $monitor[Name] ?>', <?= $jws['events'] ['w'] ?>, <?= $jws['events'] ['h'] ?> ); " >< ? = $monitor [ DayEventCount ] ?> </a></td>
< td align = " right " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=events&mid=<?= $monitor[Id] ?>&filter=1&trms=2&attr1=Archived&val1=0&cnj2=and&attr2=DateTime&op2=%3e%3d&val2=last+week', 'zmEvents<?= $monitor[Name] ?>', <?= $jws['events'] ['w'] ?>, <?= $jws['events'] ['h'] ?> ); " >< ? = $monitor [ WeekEventCount ] ?> </a></td>
< td align = " right " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=events&mid=<?= $monitor[Id] ?>&filter=1&trms=2&attr1=Archived&val1=0&cnj2=and&attr2=DateTime&op2=%3e%3d&val2=last+month', 'zmEvents<?= $monitor[Name] ?>', <?= $jws['events'] ['w'] ?>, <?= $jws['events'] ['h'] ?> ); " >< ? = $monitor [ MonthEventCount ] ?> </a></td>
< td align = " right " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=events&mid=<?= $monitor[Id] ?>&filter=1&trms=1&attr1=Archived&val1=1', 'zmEvents<?= $monitor[Name] ?>', <?= $jws['events'] ['w'] ?>, <?= $jws['events'] ['h'] ?> ); " >< ? = $monitor [ ArchEventCount ] ?> </a></td>
< td align = " right " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=zones&mid=<?= $monitor[Id] ?>', 'zmZones', <?= $monitor[Width] + $jws['zones'] ['w'] ?>, <?= $monitor[Height] + $jws['zones'] ['h'] ?> ); " >< ? = $monitor [ ZoneCount ] ?> </a></td>
< td align = " center " class = " text " >< input type = " checkbox " name = " mark_mids[] " value = " <?= $monitor[Id] ?> " onClick = " configureButton( monitor_form, 'mark_mids' ); " ></ td >
2002-10-11 17:45:06 +08:00
</ tr >
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
2003-01-31 23:44:02 +08:00
< tr >
< td colspan = " 2 " align = " center " >
< input type = " button " value = " Refresh " class = " form " onClick = " javascript: location.reload(); " >
</ td >
< td colspan = " 2 " align = " center " >
< input type = " button " value = " Add New Monitor " class = " form " onClick = " javascript: newWindow( '<?= $PHP_SELF ?>?view=monitor&zid=-1', 'zmMonitor', <?= $jws['monitor'] ['w'] ?>, <?= $jws['monitor'] ['h'] ?>); " >
</ td >
2003-01-14 00:39:00 +08:00
< td align = " right " class = " text " >< ? = $event_count ?> </td>
< td align = " right " class = " text " >< ? = $hour_event_count ?> </td>
< td align = " right " class = " text " >< ? = $day_event_count ?> </td>
< td align = " right " class = " text " >< ? = $week_event_count ?> </td>
< td align = " right " class = " text " >< ? = $month_event_count ?> </td>
< td align = " right " class = " text " >< ? = $arch_event_count ?> </td>
< td align = " right " class = " text " >< ? = $zone_count ?> </td>
2002-10-30 06:03:12 +08:00
< td align = " center " >< input type = " submit " name = " delete_btn " value = " Delete " class = " form " disabled ></ td >
2002-10-11 17:45:06 +08:00
</ tr >
</ form >
</ table >
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
2002-10-11 17:45:06 +08:00
}
2002-10-28 04:25:27 +08:00
case " cycle " :
{
2003-03-21 18:54:25 +08:00
if ( ! $mode )
{
if ( canStream () )
$mode = " stream " ;
else
$mode = " still " ;
}
2002-10-28 04:25:27 +08:00
$result = mysql_query ( " select * from Monitors where Function != 'None' order by Id " );
$monitors = array ();
$mon_idx = 0 ;
while ( $row = mysql_fetch_assoc ( $result ) )
{
if ( $mid && $row [ Id ] == $mid )
$mon_idx = count ( $monitors );
$monitors [] = $row ;
}
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$monitor = $monitors [ $mon_idx ];
$next_mid = $mon_idx == ( count ( $monitors ) - 1 ) ? $monitors [ 0 ][ Id ] : $monitors [ $mon_idx + 1 ][ Id ];
2002-10-11 17:45:06 +08:00
2003-01-14 21:19:27 +08:00
// Prompt an image to be generated
chdir ( ZM_DIR_IMAGES );
$status = exec ( escapeshellcmd ( ZMU_PATH . " -m $monitor[Id] -i " ) );
2003-03-21 18:54:25 +08:00
header ( " Refresh: " . REFRESH_CYCLE . " ; URL=' $PHP_SELF ?view=cycle&mid= $next_mid &mode= $mode ' " );
2002-10-28 04:25:27 +08:00
header ( " Expires: Mon, 26 Jul 1997 05:00:00 GMT " ); // Date in the past
header ( " Last-Modified: " . gmdate ( " D, d M Y H:i:s " ) . " GMT " ); // always modified
header ( " Cache-Control: no-store, no-cache, must-revalidate " ); // HTTP/1.1
header ( " Cache-Control: post-check=0, pre-check=0 " , false );
header ( " Pragma: no-cache " ); // HTTP/1.0
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
< title > ZM - Cycle Watch </ title >
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
2002-10-22 21:56:37 +08:00
function newWindow ( Url , Name , Width , Height )
{
var Name = window . open ( Url , Name , " resizable,scrollbars,width= " + Width + " ,height= " + Height );
2002-10-11 17:45:06 +08:00
}
2003-03-21 18:54:25 +08:00
function closeWindow ()
{
top . window . close ();
}
2002-10-11 17:45:06 +08:00
</ script >
</ head >
< body >
2003-03-21 18:54:25 +08:00
< table width = " 96% " align = " center " border = " 0 " cellspacing = " 0 " cellpadding = " 4 " >
< tr >
< td width = " 33% " align = " left " class = " text " >< b >< ? = $monitor [ Name ] ?> </b></td>
< ? php if ( $mode == " stream " ) { ?>
< td width = " 34% " align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=<?= $view ?>&mode=still&mid=<?= $mid ?> " > Stills </ a ></ td >
< ? php } elseif ( canStream () ) { ?>
< td width = " 34% " align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=<?= $view ?>&mode=stream&mid=<?= $mid ?> " > Stream </ a ></ td >
< ? php } else { ?>
< td width = " 34% " align = " center " class = " text " >& nbsp ; </ td >
< ? php } ?>
< td width = " 33% " align = " right " class = " text " >< a href = " javascript: closeWindow(); " > Close </ a ></ td >
</ tr >
< ? php
if ( $mode == " stream " )
{
$stream_src = ZMS_PATH . " ?monitor= $monitor[Id] &idle= " . STREAM_IDLE_DELAY . " &refresh= " . STREAM_FRAME_DELAY . " &ttl= " . REFRESH_CYCLE ;
if ( isNetscape () )
{
?>
< tr >< td colspan = " 3 " align = " center " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=watch&mid=<?= $monitor[Id] ?>', 'zmWatch<?= $monitor[Name] ?>', <?= $monitor[Width] + $jws['watch'] ['w'] ?>, <?= $monitor[Height] + $jws['watch'] ['h'] ?> ); " >< img src = " <?= $stream_src ?> " border = " 0 " width = " <?= $monitor[Width] ?> " height = " <?= $monitor[Height] ?> " ></ a ></ td ></ tr >
< ? php
}
else
{
?>
< tr >< td colspan = " 3 " align = " center " >< applet code = " com.charliemouse.cambozola.Viewer " archive = " <?= ZM_PATH_CAMBOZOLA ?> " align = " middle " width = " <?= $monitor[Width] ?> " height = " <?= $monitor[Height] ?> " >< param name = " url " value = " <?= $stream_src ?> " ></ applet ></ td ></ tr >
< ? php
}
}
else
{
?>
< tr >< td colspan = " 3 " align = " center " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=watch&mid=<?= $monitor[Id] ?>', 'zmWatch<?= $monitor[Name] ?>', <?= $monitor[Width] + $jws['watch'] ['w'] ?>, <?= $monitor[Height] + $jws['watch'] ['h'] ?> ); " >< img src = " <?= ZM_DIR_IMAGES.'/'. $monitor[Name] ?>.jpg " border = " 0 " width = " <?= $monitor[Width] ?> " height = " <?= $monitor[Height] ?> " ></ a ></ td ></ tr >
< ? php
}
?>
</ table >
2002-10-11 17:45:06 +08:00
</ body >
</ html >
2003-03-21 20:22:56 +08:00
< ? php
break ;
}
case " montage " :
{
$result = mysql_query ( " select * from Monitors where Function != 'None' order by Id " );
$monitors = array ();
while ( $row = mysql_fetch_assoc ( $result ) )
{
$monitors [] = $row ;
}
$rows = intval ( ceil ( count ( $monitors ) / ZM_WEB_MONTAGE_MAX_COLS ));
$cols = count ( $monitors ) >= ZM_WEB_MONTAGE_MAX_COLS ? ZM_WEB_MONTAGE_MAX_COLS : count ( $monitors );
$widths = array ();
$heights = array ();
for ( $i = 0 ; $i < count ( $monitors ); $i ++ )
{
$monitor = $monitors [ $i ];
$frame_height = $monitor [ Height ] + 16 ;
$row = $i / ZM_WEB_MONTAGE_MAX_COLS ;
$col = $i % ZM_WEB_MONTAGE_MAX_COLS ;
if ( $frame_height > $heights [ $row ] )
$heights [ $row ] = $frame_height ;
if ( $monitor [ Width ] > $widths [ $col ] )
$widths [ $col ] = $monitor [ Width ];
}
$row_spec = join ( ',' , $heights );
$col_spec = join ( ',' , $widths );
?>
< html >
< head >
< title > ZM - Montage </ title >
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2003-03-21 20:22:56 +08:00
< script language = " JavaScript " >
//window.resizeTo( <?= $jws['montage']['w']*$cols ?>, <?= $jws['montage']['h']*$rows ?> );
window . focus ();
</ script >
</ head >
< frameset rows = " <?= $row_spec ?> " cols = " <?= $col_spec ?> " border = " 1 " frameborder = " no " framespacing = " 0 " >
< ? php
for ( $row = 0 ; $row < $rows ; $row ++ )
{
for ( $col = 0 ; $col < $cols ; $col ++ )
{
$i = ( $row * $cols ) + $col ;
if ( $i < count ( $monitors ) )
{
$monitor = $monitors [ $i ];
?>
< frameset rows = " *,16 " cols = " 100% " border = " 1 " frameborder = " no " framespacing = " 0 " >
< frame src = " <?= $PHP_SELF ?>?view=montagefeed&mid=<?= $monitor[Id] ?> " marginwidth = " 0 " marginheight = " 0 " name = " MonitorStream " scrolling = " no " >
< frame src = " <?= $PHP_SELF ?>?view=montagestatus&mid=<?= $monitor[Id] ?> " marginwidth = " 0 " marginheight = " 0 " name = " MonitorStatus " scrolling = " no " >
</ frameset >
< ? php
}
}
}
?>
</ frameset >
< ? php
break ;
}
case " montagehead " :
{
?>
< html >
< head >
< title > ZM - Montage Header </ title >
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2003-03-21 20:22:56 +08:00
< script language = " JavaScript " >
function closeWindow ()
{
top . window . close ();
}
</ script >
</ head >
< body >
< table width = " 96% " align = " center " border = " 0 " cellspacing = " 0 " cellpadding = " 4 " >
</ table >
</ body >
</ html >
< ? php
break ;
}
case " montagefeed " :
{
if ( ! $mode )
{
if ( canStream () )
$mode = " stream " ;
else
$mode = " still " ;
}
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
if ( $mode != " stream " )
{
// Prompt an image to be generated
chdir ( ZM_DIR_IMAGES );
$status = exec ( escapeshellcmd ( ZMU_PATH . " -m $mid -i " ) );
chdir ( '..' );
header ( " Refresh: " . REFRESH_IMAGE . " ; URL=' $PHP_SELF ?view=montagefeed&mid= $mid &mode=still' " );
}
header ( " Expires: Mon, 26 Jul 1997 05:00:00 GMT " ); // Date in the past
header ( " Last-Modified: " . gmdate ( " D, d M Y H:i:s " ) . " GMT " ); // always modified
header ( " Cache-Control: no-store, no-cache, must-revalidate " ); // HTTP/1.1
header ( " Cache-Control: post-check=0, pre-check=0 " , false );
header ( " Pragma: no-cache " ); // HTTP/1.0
?>
< html >
< head >
< title > ZM - < ? = $monitor [ Name ] ?> - MontageFeed</title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2003-03-21 20:22:56 +08:00
</ head >
< body >
< table width = " 96% " align = " center " border = " 0 " cellspacing = " 0 " cellpadding = " 4 " >
< tr >
< td width = " 50% " align = " center " class = " text " >< b >< ? = $monitor [ Name ] ?> </b></td>
< ? php if ( $mode == " stream " ) { ?>
< td width = " 50% " align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=montagefeed&mode=still&mid=<?= $mid ?> " > Stills </ a ></ td >
< ? php } elseif ( canStream () ) { ?>
< td width = " 50% " align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=montagefeed&mode=stream&mid=<?= $mid ?> " > Stream </ a ></ td >
< ? php } else { ?>
< td width = " 50% " align = " center " class = " text " >& nbsp ; </ td >
< ? php } ?>
</ tr >
< ? php
if ( $mode == " stream " )
{
$stream_src = ZMS_PATH . " ?monitor= $monitor[Id] &idle= " . STREAM_IDLE_DELAY . " &refresh= " . STREAM_FRAME_DELAY ;
if ( isNetscape () )
{
?>
< tr >< td colspan = " 2 " align = " center " >< img src = " <?= $stream_src ?> " border = " 0 " width = " <?= $monitor[Width] ?> " height = " <?= $monitor[Height] ?> " ></ td ></ tr >
< ? php
}
else
{
?>
< tr >< td colspan = " 2 " align = " center " >< applet code = " com.charliemouse.cambozola.Viewer " archive = " <?= ZM_PATH_CAMBOZOLA ?> " align = " middle " width = " <?= $monitor[Width] ?> " height = " <?= $monitor[Height] ?> " >< param name = " url " value = " <?= $stream_src ?> " ></ applet ></ td ></ tr >
< ? php
}
}
else
{
?>
< tr >< td colspan = " 2 " align = " center " >< img src = " <?= ZM_DIR_IMAGES.'/'. $monitor[Name] ?>.jpg " border = " 0 " width = " <?= $monitor[Width] ?> " height = " <?= $monitor[Height] ?> " ></ td ></ tr >
< ? php
}
?>
</ table >
</ body >
</ html >
< ? php
break ;
}
case " montagestatus " :
{
$zmu_command = ZMU_PATH . " -m $mid -s -f " ;
$zmu_output = exec ( escapeshellcmd ( $zmu_command ) );
list ( $status , $fps ) = split ( ' ' , $zmu_output );
$status_string = " Unknown " ;
$fps_string = " --.-- " ;
$class = " text " ;
if ( $status == 0 )
{
$status_string = " Idle " ;
}
elseif ( $status == 1 )
{
$status_string = " Alarm " ;
$class = " redtext " ;
}
elseif ( $status == 2 )
{
$status_string = " Alert " ;
$class = " oratext " ;
}
$fps_string = sprintf ( " %.2f " , $fps );
$new_alarm = ( $status > 0 && $last_status == 0 );
$old_alarm = ( $status == 0 && $last_status > 0 );
$refresh = ( isset ( $force ) || $forced || $status ) ? 1 : REFRESH_STATUS ;
$url = " $PHP_SELF ?view=montagestatus&mid= $mid &last_status= $status " ;
header ( " Refresh: $refresh ; URL=' $url ' " );
header ( " Expires: Mon, 26 Jul 1997 05:00:00 GMT " ); // Date in the past
header ( " Last-Modified: " . gmdate ( " D, d M Y H:i:s " ) . " GMT " ); // always modified
header ( " Cache-Control: no-store, no-cache, must-revalidate " ); // HTTP/1.1
header ( " Cache-Control: post-check=0, pre-check=0 " , false );
header ( " Pragma: no-cache " ); // HTTP/1.0
?>
< html >
< head >
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2003-03-21 20:22:56 +08:00
< script language = " JavaScript " >
< ? php
if ( ZM_WEB_POPUP_ON_ALARM && $new_alarm )
{
?>
top . window . focus ();
< ? php
}
?>
</ script >
</ head >
< body >
< table width = " 90% " align = " center " border = " 0 " cellpadding = " 0 " cellspacing = " 0 " >
< tr >
< td width = " 30% " class = " text " align = " left " >& nbsp ; </ td >
< td width = " 40% " class = " <?= $class ?> " align = " center " valign = " middle " > Status :& nbsp ; < ? = $status_string ?> - <?= $fps_string ?> fps</td>
< td width = " 30% " align = " right " class = " text " >& nbsp ; </ td >
</ tr >
</ table >
< ? php
if ( ZM_WEB_SOUND_ON_ALARM && $status == 1 )
{
?>
< embed src = " <?= ZM_DIR_SOUNDS.'/'.ZM_WEB_ALARM_SOUND ?> " autostart = " yes " hidden = " true " ></ embed >
< ? php
}
?>
</ body >
</ html >
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
break ;
}
case " watch " :
{
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - < ? = $monitor [ Name ] ?> - Watch</title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
2003-03-12 00:01:56 +08:00
opener . location . reload ();
2002-10-11 17:45:06 +08:00
window . focus ();
</ script >
</ head >
2003-01-14 00:39:00 +08:00
< frameset rows = " <?= $monitor[Height] +32 ?>,16,* " border = " 1 " frameborder = " no " framespacing = " 0 " >
< frame src = " <?= $PHP_SELF ?>?view=watchfeed&mid=<?= $monitor[Id] ?> " marginwidth = " 0 " marginheight = " 0 " name = " MonitorStream " scrolling = " no " >
< frame src = " <?= $PHP_SELF ?>?view=watchstatus&mid=<?= $monitor[Id] ?> " marginwidth = " 0 " marginheight = " 0 " name = " MonitorStatus " scrolling = " no " >
< frame src = " <?= $PHP_SELF ?>?view=watchevents&max_events=<?= MAX_EVENTS ?>&mid=<?= $monitor[Id] ?> " marginwidth = " 0 " marginheight = " 0 " name = " MonitorEvents " scrolling = " auto " >
2002-10-11 17:45:06 +08:00
</ frameset >
< ? php
2002-10-28 04:25:27 +08:00
break ;
2002-10-11 17:45:06 +08:00
}
2002-10-28 04:25:27 +08:00
case " watchfeed " :
{
if ( ! $mode )
{
if ( canStream () )
$mode = " stream " ;
else
$mode = " still " ;
}
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
if ( $mode != " stream " )
{
2003-01-03 23:07:55 +08:00
// Prompt an image to be generated
2003-01-11 06:29:02 +08:00
chdir ( ZM_DIR_IMAGES );
2003-01-03 23:07:55 +08:00
$status = exec ( escapeshellcmd ( ZMU_PATH . " -m $mid -i " ) );
2003-01-04 00:37:17 +08:00
chdir ( '..' );
2002-10-28 04:25:27 +08:00
header ( " Refresh: " . REFRESH_IMAGE . " ; URL=' $PHP_SELF ?view=watchfeed&mid= $mid &mode=still' " );
}
2003-01-16 23:34:50 +08:00
header ( " Expires: Mon, 26 Jul 1997 05:00:00 GMT " ); // Date in the past
header ( " Last-Modified: " . gmdate ( " D, d M Y H:i:s " ) . " GMT " ); // always modified
header ( " Cache-Control: no-store, no-cache, must-revalidate " ); // HTTP/1.1
header ( " Cache-Control: post-check=0, pre-check=0 " , false );
header ( " Pragma: no-cache " ); // HTTP/1.0
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
2003-01-16 22:55:17 +08:00
< title > ZM - < ? = $monitor [ Name ] ?> - WatchFeed</title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
2002-10-22 21:56:37 +08:00
function closeWindow ()
{
2002-10-11 17:45:06 +08:00
top . window . close ();
}
</ script >
</ head >
< body >
< table width = " 96% " align = " center " border = " 0 " cellspacing = " 0 " cellpadding = " 4 " >
< tr >
2003-01-14 00:39:00 +08:00
< td width = " 33% " align = " left " class = " text " >< b >< ? = $monitor [ Name ] ?> </b></td>
2002-10-11 17:45:06 +08:00
< ? php if ( $mode == " stream " ) { ?>
2003-01-14 00:39:00 +08:00
< td width = " 34% " align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchfeed&mode=still&mid=<?= $mid ?> " > Stills </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } elseif ( canStream () ) { ?>
2003-01-14 00:39:00 +08:00
< td width = " 34% " align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchfeed&mode=stream&mid=<?= $mid ?> " > Stream </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } else { ?>
< td width = " 34% " align = " center " class = " text " >& nbsp ; </ td >
< ? php } ?>
< td width = " 33% " align = " right " class = " text " >< a href = " javascript: closeWindow(); " > Close </ a ></ td >
</ tr >
2002-10-28 04:25:27 +08:00
< ? php
if ( $mode == " stream " )
{
$stream_src = ZMS_PATH . " ?monitor= $monitor[Id] &idle= " . STREAM_IDLE_DELAY . " &refresh= " . STREAM_FRAME_DELAY ;
if ( isNetscape () )
{
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< tr >< td colspan = " 3 " align = " center " >< img src = " <?= $stream_src ?> " border = " 0 " width = " <?= $monitor[Width] ?> " height = " <?= $monitor[Height] ?> " ></ td ></ tr >
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
else
{
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< tr >< td colspan = " 3 " align = " center " >< applet code = " com.charliemouse.cambozola.Viewer " archive = " <?= ZM_PATH_CAMBOZOLA ?> " align = " middle " width = " <?= $monitor[Width] ?> " height = " <?= $monitor[Height] ?> " >< param name = " url " value = " <?= $stream_src ?> " ></ applet ></ td ></ tr >
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
}
else
{
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< tr >< td colspan = " 3 " align = " center " >< img src = " <?= ZM_DIR_IMAGES.'/'. $monitor[Name] ?>.jpg " border = " 0 " width = " <?= $monitor[Width] ?> " height = " <?= $monitor[Height] ?> " ></ td ></ tr >
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
</ table >
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
2002-10-11 17:45:06 +08:00
}
2002-10-28 04:25:27 +08:00
case " watchstatus " :
2002-10-11 17:45:06 +08:00
{
2003-01-24 23:56:28 +08:00
$zmu_command = ZMU_PATH . " -m $mid -s -f " ;
if ( isset ( $force ) )
{
$zmu_command .= ( $force ? " -a " : " -c " );
}
$zmu_output = exec ( escapeshellcmd ( $zmu_command ) );
2003-01-13 18:52:05 +08:00
list ( $status , $fps ) = split ( ' ' , $zmu_output );
2002-10-28 04:25:27 +08:00
$status_string = " Unknown " ;
2003-01-13 18:52:05 +08:00
$fps_string = " --.-- " ;
2002-10-28 04:25:27 +08:00
$class = " text " ;
if ( $status == 0 )
{
$status_string = " Idle " ;
}
elseif ( $status == 1 )
{
$status_string = " Alarm " ;
$class = " redtext " ;
}
elseif ( $status == 2 )
{
$status_string = " Alert " ;
$class = " oratext " ;
}
2003-01-13 18:52:05 +08:00
$fps_string = sprintf ( " %.2f " , $fps );
2002-10-28 04:25:27 +08:00
$new_alarm = ( $status > 0 && $last_status == 0 );
2003-01-25 00:02:18 +08:00
$old_alarm = ( $status == 0 && $last_status > 0 );
2002-10-11 17:45:06 +08:00
2003-01-24 23:56:28 +08:00
$refresh = ( isset ( $force ) || $forced || $status ) ? 1 : REFRESH_STATUS ;
$url = " $PHP_SELF ?view=watchstatus&mid= $mid &last_status= $status " . (( $force || $forced ) ? " &forced=1 " : " " );
header ( " Refresh: $refresh ; URL=' $url ' " );
2002-10-28 04:25:27 +08:00
header ( " Expires: Mon, 26 Jul 1997 05:00:00 GMT " ); // Date in the past
header ( " Last-Modified: " . gmdate ( " D, d M Y H:i:s " ) . " GMT " ); // always modified
header ( " Cache-Control: no-store, no-cache, must-revalidate " ); // HTTP/1.1
header ( " Cache-Control: post-check=0, pre-check=0 " , false );
header ( " Pragma: no-cache " ); // HTTP/1.0
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
< ? php
2003-01-11 01:12:23 +08:00
if ( ZM_WEB_POPUP_ON_ALARM && $new_alarm )
2002-10-28 04:25:27 +08:00
{
2002-10-11 17:45:06 +08:00
?>
top . window . focus ();
2003-01-25 00:02:18 +08:00
< ? php
}
if ( $old_alarm )
{
?>
parent . frames [ 2 ] . location . reload ();
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
</ script >
</ head >
< body >
2003-01-24 23:56:28 +08:00
< table width = " 90% " align = " center " border = " 0 " cellpadding = " 0 " cellspacing = " 0 " >
< tr >
< td width = " 30% " class = " text " align = " left " >& nbsp ; </ td >
< td width = " 40% " class = " <?= $class ?> " align = " center " valign = " middle " > Status :& nbsp ; < ? = $status_string ?> - <?= $fps_string ?> fps</td>
< ? php
if ( $force || $forced )
{
?>
< td width = " 30% " align = " right " class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchstatus&mid=<?= $mid ?>&last_status= $status &force=0 " > Cancel Forced Alarm </ a ></ td >
< ? php
}
elseif ( zmaCheck ( $mid ) )
{
?>
< td width = " 30% " align = " right " class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchstatus&mid=<?= $mid ?>&last_status= $status &force=1 " > Force Alarm </ a ></ td >
< ? php
}
else
{
?>
< td width = " 30% " align = " right " class = " text " >& nbsp ; </ td >
< ? php
}
?>
</ tr >
</ table >
2002-10-11 17:45:06 +08:00
< ? php
2003-01-11 01:12:23 +08:00
if ( ZM_WEB_SOUND_ON_ALARM && $status == 1 )
2002-10-28 04:25:27 +08:00
{
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< embed src = " <?= ZM_DIR_SOUNDS.'/'.ZM_WEB_ALARM_SOUND ?> " autostart = " yes " hidden = " true " ></ embed >
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
2002-10-11 17:45:06 +08:00
}
2002-10-28 04:25:27 +08:00
case " watchevents " :
{
switch ( $sort_field )
{
case 'Id' :
$sort_column = " E.Id " ;
break ;
case 'Name' :
$sort_column = " E.Name " ;
break ;
case 'Time' :
$sort_column = " E.StartTime " ;
break ;
case 'Secs' :
$sort_column = " E.Length " ;
break ;
case 'Frames' :
$sort_column = " E.Frames " ;
break ;
case 'Score' :
$sort_column = " E.AvgScore " ;
break ;
default :
$sort_field = " Time " ;
$sort_column = " E.StartTime " ;
break ;
}
$sort_order = $sort_asc ? " asc " : " desc " ;
if ( ! $sort_asc )
$sort_asc = 0 ;
header ( " Refresh: " . REFRESH_EVENTS . " ; URL=' $PHP_SELF ?view=watchevents&mid= $mid &max_events= " . MAX_EVENTS . " ' " );
header ( " Expires: Mon, 26 Jul 1997 05:00:00 GMT " ); // Date in the past
header ( " Last-Modified: " . gmdate ( " D, d M Y H:i:s " ) . " GMT " ); // always modified
header ( " Cache-Control: no-store, no-cache, must-revalidate " ); // HTTP/1.1
header ( " Cache-Control: post-check=0, pre-check=0 " , false );
header ( " Pragma: no-cache " ); // HTTP/1.0
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - < ? = $monitor ?> - Events</title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
2002-10-28 03:57:22 +08:00
function newWindow ( Url , Name , Width , Height )
2002-10-22 21:56:37 +08:00
{
2002-10-28 03:57:22 +08:00
var Name = window . open ( Url , Name , " resizable,scrollbars,width= " + Width + " ,height= " + Height );
2002-10-11 17:45:06 +08:00
}
2002-10-22 21:56:37 +08:00
function closeWindow ()
{
top . window . close ();
2002-10-11 17:45:06 +08:00
}
function checkAll ( form , name ){
for ( var i = 0 ; i < form . elements . length ; i ++ )
if ( form . elements [ i ] . name . indexOf ( name ) == 0 )
form . elements [ i ] . checked = 1 ;
2003-03-12 00:01:56 +08:00
form . delete_btn . disabled = false ;
2002-10-11 17:45:06 +08:00
}
2002-10-30 06:03:12 +08:00
function configureButton ( form , name )
{
var checked = false ;
for ( var i = 0 ; i < form . elements . length ; i ++ )
{
if ( form . elements [ i ] . name . indexOf ( name ) == 0 )
{
if ( form . elements [ i ] . checked )
{
checked = true ;
break ;
}
}
}
form . delete_btn . disabled = ! checked ;
}
2002-10-11 17:45:06 +08:00
</ script >
</ head >
< body >
2003-01-14 00:39:00 +08:00
< form name = " event_form " method = " get " action = " <?= $PHP_SELF ?> " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
2002-10-11 17:45:06 +08:00
< input type = " hidden " name = " action " value = " delete " >
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " mid " value = " <?= $mid ?> " >
< input type = " hidden " name = " max_events " value = " <?= $max_events ?> " >
2002-10-11 17:45:06 +08:00
< center >< table width = " 96% " align = " center " border = " 0 " cellspacing = " 1 " cellpadding = " 0 " >
< tr >
< td valign = " top " >< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< ? php
2002-10-28 04:25:27 +08:00
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
2002-10-28 03:57:22 +08:00
2003-04-07 19:17:01 +08:00
$sql = " select E.Id,E.Name,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.AvgScore,E.MaxScore from Monitors as M, Events as E where M.Id = ' $mid ' and M.Id = E.MonitorId and E.Archived = 0 " ;
2002-10-28 04:25:27 +08:00
$sql .= " order by $sort_column $sort_order " ;
$sql .= " limit 0, $max_events " ;
$result = mysql_query ( $sql );
if ( ! $result )
{
die ( mysql_error () );
}
$n_rows = mysql_num_rows ( $result );
2002-10-11 17:45:06 +08:00
?>
< tr >
2003-01-14 00:39:00 +08:00
< td class = " text " >< b > Last < ? = $n_rows ?> events</b></td>
< td align = " center " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=events&mid=<?= $monitor[Id] ?>&filter=1&trms=0', 'zmEvents<?= $monitor[Name] ?>', <?= $jws['events'] ['w'] ?>, <?= $jws['events'] ['h'] ?> ); " > All </ a ></ td >
< td align = " center " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=events&mid=<?= $monitor[Id] ?>&filter=1&trms=1&attr1=Archived&val1=1', 'zmEvents<?= $monitor[Name] ?>', <?= $jws['events'] ['w'] ?>, <?= $jws['events'] ['h'] ?> ); " > Archive </ a ></ td >
2002-11-07 20:23:54 +08:00
< td align = " right " class = " text " >< a href = " javascript: checkAll( event_form, 'mark_eids' ); " > Check All </ a ></ td >
2002-10-11 17:45:06 +08:00
</ tr >
< tr >< td colspan = " 5 " class = " text " >& nbsp ; </ td ></ tr >
2003-04-11 23:42:54 +08:00
< tr >< td colspan = " 5 " >< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " bgcolor = " #7F7FB2 " >
< tr align = " center " bgcolor = " #FFFFFF " >
2003-01-14 00:39:00 +08:00
< td width = " 4% " class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Id&sort_asc=<?= $sort_field == 'Id'?! $sort_asc :0 ?> " > Id < ? php if ( $sort_field == " Id " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td width = " 24% " class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Name&sort_asc=<?= $sort_field == 'Name'?! $sort_asc :0 ?> " > Name < ? php if ( $sort_field == " Name " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Time&sort_asc=<?= $sort_field == 'Time'?! $sort_asc :0 ?> " > Time < ? php if ( $sort_field == " Time " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Secs&sort_asc=<?= $sort_field == 'Secs'?! $sort_asc :0 ?> " > Secs < ? php if ( $sort_field == " Secs " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Frames&sort_asc=<?= $sort_field == 'Frames'?! $sort_asc :0 ?> " > Frames < ? php if ( $sort_field == " Frames " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=watchevents&mid=<?= $mid ?>&max_events=<?= $max_events ?>&sort_field=Score&sort_asc=<?= $sort_field == 'Score'?! $sort_asc :0 ?> " > Score < ? php if ( $sort_field == " Score " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
2002-10-30 06:03:12 +08:00
< td class = " text " > Mark </ td >
2002-10-11 17:45:06 +08:00
</ tr >
< ? php
2002-10-28 04:25:27 +08:00
while ( $row = mysql_fetch_assoc ( $result ) )
{
2002-10-11 17:45:06 +08:00
?>
2003-04-11 23:42:54 +08:00
< tr bgcolor = " #FFFFFF " >
2003-04-07 19:38:23 +08:00
< td align = " center " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=event&mid=<?= $mid ?>&eid=<?= $row[Id] ?>', 'zmEvent', <?= $jws['event'] ['w'] ?>, <?= $jws['event'] ['h'] ?> ); " >< ? = $row [ Id ] ?> </a></td>
< td align = " center " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=event&mid=<?= $mid ?>&eid=<?= $row[Id] ?>', 'zmEvent', <?= $jws['event'] ['w'] ?>, <?= $jws['event'] ['h'] ?> ); " >< ? = $row [ Name ] ?> </a></td>
2003-04-07 19:17:01 +08:00
< td align = " center " class = " text " >< ? = strftime ( " %m/%d %H:%M:%S " , strtotime ( $row [ StartTime ]) ) ?> </td>
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< ? = $row [ Length ] ?> </td>
2003-03-28 01:14:34 +08:00
< td align = " center " class = " text " >< ? = $row [ Frames ] ?> /<?= $row[AlarmFrames] ?></td>
< td align = " center " class = " text " >< ? = $row [ AvgScore ] ?> /<?= $row[MaxScore] ?></td>
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< input type = " checkbox " name = " mark_eids[] " value = " <?= $row[Id] ?> " onClick = " configureButton( event_form, 'mark_eids' ); " ></ td >
2002-10-11 17:45:06 +08:00
</ tr >
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
</ table ></ td ></ tr >
</ table ></ td >
</ tr >
2002-10-30 06:03:12 +08:00
< tr >< td align = " right " >< input type = " submit " name = " delete_btn " value = " Delete " class = " form " disabled ></ td ></ tr >
2002-10-11 17:45:06 +08:00
</ table ></ center >
</ form >
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
2002-10-17 06:12:32 +08:00
}
2002-10-28 04:25:27 +08:00
case " events " :
2002-10-17 06:12:32 +08:00
{
2002-10-28 04:25:27 +08:00
switch ( $sort_field )
2002-10-17 06:12:32 +08:00
{
2002-10-28 04:25:27 +08:00
case 'Id' :
$sort_column = " E.Id " ;
break ;
case 'Name' :
$sort_column = " E.Name " ;
break ;
case 'Time' :
$sort_column = " E.StartTime " ;
break ;
case 'Secs' :
$sort_column = " E.Length " ;
break ;
case 'Frames' :
$sort_column = " E.Frames " ;
break ;
case 'AlarmFrames' :
$sort_column = " E.AlarmFrames " ;
break ;
2003-01-07 22:32:23 +08:00
case 'TotScore' :
$sort_column = " E.TotScore " ;
break ;
2002-10-28 04:25:27 +08:00
case 'AvgScore' :
$sort_column = " E.AvgScore " ;
break ;
case 'MaxScore' :
$sort_column = " E.MaxScore " ;
break ;
default :
$sort_field = " Time " ;
$sort_column = " E.StartTime " ;
break ;
2002-10-17 06:12:32 +08:00
}
2002-10-28 04:25:27 +08:00
$sort_order = $sort_asc ? " asc " : " desc " ;
if ( ! $sort_asc ) $sort_asc = 0 ;
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
// XXX
2003-04-07 19:17:01 +08:00
$sql = " select E.Id,E.Name,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived,E.LearnState from Monitors as M, Events as E where M.Id = ' $mid ' and M.Id = E.MonitorId " ;
2002-10-28 04:25:27 +08:00
$filter_query = '' ;
$filter_sql = '' ;
$filter_fields = '' ;
if ( $trms )
2002-10-17 06:12:32 +08:00
{
2002-10-28 04:25:27 +08:00
$filter_query .= " &trms= $trms " ;
$filter_fields .= '<input type="hidden" name="trms" value="' . $trms . '">' . " \n " ;
2002-10-22 21:56:37 +08:00
}
2002-10-28 04:25:27 +08:00
for ( $i = 1 ; $i <= $trms ; $i ++ )
2002-10-22 21:56:37 +08:00
{
2002-10-28 04:25:27 +08:00
$conjunction_name = " cnj $i " ;
$obracket_name = " obr $i " ;
$cbracket_name = " cbr $i " ;
$attr_name = " attr $i " ;
$op_name = " op $i " ;
$value_name = " val $i " ;
if ( $$conjunction_name )
{
$filter_query .= " & $conjunction_name = " . $$conjunction_name ;
$filter_sql .= " " . $$conjunction_name . " " ;
$filter_fields .= '<input type="hidden" name="' . $conjunction_name . '" value="' . $$conjunction_name . '">' . " \n " ;
}
if ( $$obracket_name )
{
$filter_query .= " & $obracket_name = " . $$obracket_name ;
$filter_sql .= str_repeat ( " ( " , $$obracket_name );
$filter_fields .= '<input type="hidden" name="' . $obracket_name . '" value="' . $$obracket_name . '">' . " \n " ;
}
if ( $$attr_name )
2002-10-22 21:56:37 +08:00
{
2002-10-28 04:25:27 +08:00
$filter_query .= " & $attr_name = " . $$attr_name ;
$filter_fields .= '<input type="hidden" name="' . $attr_name . '" value="' . $$attr_name . '">' . " \n " ;
switch ( $$attr_name )
{
case 'DateTime' :
2002-10-30 20:29:36 +08:00
$dt_val = strtotime ( $$value_name );
$filter_sql .= " E.StartTime " . $$op_name . " from_unixtime( $dt_val ) " ;
2002-10-28 04:25:27 +08:00
$filter_query .= " & $op_name = " . urlencode ( $$op_name );
$filter_fields .= '<input type="hidden" name="' . $op_name . '" value="' . $$op_name . '">' . " \n " ;
break ;
case 'Date' :
2002-10-30 20:29:36 +08:00
$dt_val = strtotime ( $$value_name );
$filter_sql .= " to_days( E.StartTime ) " . $$op_name . " to_days( from_unixtime( $dt_val ) ) " ;
2002-10-28 04:25:27 +08:00
$filter_query .= " & $op_name = " . urlencode ( $$op_name );
$filter_fields .= '<input type="hidden" name="' . $op_name . '" value="' . $$op_name . '">' . " \n " ;
break ;
case 'Time' :
2002-10-30 20:29:36 +08:00
$dt_val = strtotime ( $$value_name );
$filter_sql .= " extract( hour_second from E.StartTime ) " . $$op_name . " extract( hour_second from from_unixtime( $dt_val ) ) " ;
2002-10-28 04:25:27 +08:00
$filter_query .= " & $op_name = " . urlencode ( $$op_name );
$filter_fields .= '<input type="hidden" name="' . $op_name . '" value="' . $$op_name . '">' . " \n " ;
break ;
2002-10-30 06:03:12 +08:00
case 'Weekday' :
2002-10-30 20:29:36 +08:00
$dt_val = strtotime ( $$value_name );
$filter_sql .= " weekday( E.StartTime ) " . $$op_name . " weekday( from_unixtime( $dt_val ) ) " ;
2002-10-30 06:03:12 +08:00
$filter_query .= " & $op_name = " . urlencode ( $$op_name );
$filter_fields .= '<input type="hidden" name="' . $op_name . '" value="' . $$op_name . '">' . " \n " ;
break ;
2002-10-28 04:25:27 +08:00
case 'Length' :
case 'Frames' :
case 'AlarmFrames' :
2003-01-07 22:32:23 +08:00
case 'TotScore' :
2002-10-28 04:25:27 +08:00
case 'AvgScore' :
case 'MaxScore' :
$filter_sql .= " E. " . $$attr_name . " " . $$op_name . " " . $$value_name ;
$filter_query .= " & $op_name = " . urlencode ( $$op_name );
$filter_fields .= '<input type="hidden" name="' . $op_name . '" value="' . $$op_name . '">' . " \n " ;
break ;
case 'Archived' :
$filter_sql .= " E.Archived = " . $$value_name ;
break ;
}
$filter_query .= " & $value_name = " . urlencode ( $$value_name );
$filter_fields .= '<input type="hidden" name="' . $value_name . '" value="' . $$value_name . '">' . " \n " ;
}
if ( $$cbracket_name )
{
$filter_query .= " & $cbracket_name = " . $$cbracket_name ;
$filter_sql .= str_repeat ( " ) " , $$cbracket_name );
$filter_fields .= '<input type="hidden" name="' . $cbracket_name . '" value="' . $$cbracket_name . '">' . " \n " ;
2002-10-22 21:56:37 +08:00
}
}
2002-10-28 04:25:27 +08:00
if ( $filter_sql )
2002-10-22 21:56:37 +08:00
{
2002-10-28 04:25:27 +08:00
$sql .= " and ( $filter_sql ) " ;
2002-10-17 06:12:32 +08:00
}
2002-10-28 04:25:27 +08:00
$sql .= " order by $sort_column $sort_order " ;
//echo $sql;
$result = mysql_query ( $sql );
if ( ! $result )
{
die ( mysql_error () );
}
$n_rows = mysql_num_rows ( $result );
2002-10-17 06:12:32 +08:00
2002-10-28 04:25:27 +08:00
//echo $filter_query;
2002-10-17 06:12:32 +08:00
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - < ? = $monitor [ Name ] ?> - Events</title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-17 06:12:32 +08:00
< script language = " JavaScript " >
2002-10-22 21:56:37 +08:00
function eventWindow ( Url , Name )
{
2003-01-14 00:39:00 +08:00
var Name = window . open ( Url , Name , " resizable,scrollbars,width=<?= $jws['event'] ['w'] ?>,height=<?= $jws['event'] ['h'] ?> " );
2002-10-17 06:12:32 +08:00
}
2002-10-22 21:56:37 +08:00
function filterWindow ( Url , Name )
{
2003-01-14 00:39:00 +08:00
var Name = window . open ( Url , Name , " resizable,scrollbars,width=<?= $jws['filter'] ['w'] ?>,height=<?= $jws['filter'] ['h'] ?> " );
2002-10-22 21:56:37 +08:00
}
function closeWindow ()
{
window . close ();
// This is a hack. The only way to close an existing window is to try and open it!
2003-01-14 00:39:00 +08:00
var filterWindow = window . open ( " <?= $PHP_SELF ?>?view=none " , 'zmFilter<?= $monitor[Name] ?>' , 'width=1,height=1' );
2002-10-22 21:56:37 +08:00
filterWindow . close ();
2002-10-17 06:12:32 +08:00
}
function checkAll ( form , name ){
for ( var i = 0 ; i < form . elements . length ; i ++ )
if ( form . elements [ i ] . name . indexOf ( name ) == 0 )
form . elements [ i ] . checked = 1 ;
2002-10-22 21:56:37 +08:00
form . delete_btn . disabled = false ;
2003-01-07 19:21:57 +08:00
< ? php if ( LEARN_MODE ) { ?>
2002-11-07 20:23:54 +08:00
form . learn_btn . disabled = false ;
form . learn_state . disabled = false ;
2003-01-07 19:21:57 +08:00
< ? php } ?>
2002-10-17 06:12:32 +08:00
}
2002-10-22 21:56:37 +08:00
function configureButton ( form , name )
2002-10-17 06:12:32 +08:00
{
2002-10-22 21:56:37 +08:00
var checked = false ;
for ( var i = 0 ; i < form . elements . length ; i ++ )
2002-10-17 06:12:32 +08:00
{
2002-10-22 21:56:37 +08:00
if ( form . elements [ i ] . name . indexOf ( name ) == 0 )
{
if ( form . elements [ i ] . checked )
{
checked = true ;
break ;
}
}
2002-10-17 06:12:32 +08:00
}
2002-10-22 21:56:37 +08:00
form . delete_btn . disabled = ! checked ;
2003-01-07 19:21:57 +08:00
< ? php if ( LEARN_MODE ) { ?>
2002-11-07 20:23:54 +08:00
form . learn_btn . disabled = ! checked ;
form . learn_state . disabled = ! checked ;
2003-01-07 19:21:57 +08:00
< ? php } ?>
2002-10-17 06:12:32 +08:00
}
2002-10-30 23:37:16 +08:00
window . focus ();
2002-10-22 21:56:37 +08:00
< ? php if ( $filter ) { ?>
2003-03-12 00:01:56 +08:00
opener . location . reload ();
2003-01-14 00:39:00 +08:00
filterWindow ( '<?= $PHP_SELF ?>?view=filter&mid=<?= $mid ?><?= $filter_query ?>' , 'zmFilter<?= $monitor[Name] ?>' );
location . href = '<?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?>' ;
2002-10-22 21:56:37 +08:00
< ? php } ?>
2002-10-17 06:12:32 +08:00
</ script >
</ head >
< body >
2003-01-14 00:39:00 +08:00
< form name = " event_form " method = " post " action = " <?= $PHP_SELF ?> " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
2002-10-17 06:12:32 +08:00
< input type = " hidden " name = " action " value = " " >
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " mid " value = " <?= $mid ?> " >
2002-10-22 21:56:37 +08:00
< ? php if ( $filter_fields ) echo $filter_fields ?>
2002-10-17 06:12:32 +08:00
< center >< table width = " 96% " align = " center " border = " 0 " cellspacing = " 1 " cellpadding = " 0 " >
< tr >
< td valign = " top " >< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tr >
2003-01-14 00:39:00 +08:00
< td align = " left " class = " text " width = " 33% " >< b >< ? = $monitor [ Name ] ?> - <?= $n_rows ?> events</b></td>
2002-10-22 21:56:37 +08:00
< td align = " center " class = " text " width = " 34% " >& nbsp ; </ td >
< td align = " right " class = " text " width = " 33% " >< a href = " javascript: closeWindow(); " > Close </ a ></ td >
2002-10-17 06:12:32 +08:00
</ tr >
2002-10-22 21:56:37 +08:00
< tr >< td colspan = " 3 " class = " text " >& nbsp ; </ td ></ tr >
2002-10-17 06:12:32 +08:00
< tr >
2002-10-22 21:56:37 +08:00
< td align = " right " class = " text " >< a href = " javascript: location.reload(); " > Refresh </ td >
2003-01-14 00:39:00 +08:00
< td align = " right " class = " text " >< a href = " javascript: filterWindow( '<?= $PHP_SELF ?>?view=filter&mid=<?= $mid ?><?= $filter_query ?>', 'zmFilter<?= $monitor[Name] ?>' ); " > Show Filter Window </ a ></ td >
2002-11-07 20:23:54 +08:00
< td align = " right " class = " text " >< a href = " javascript: checkAll( event_form, 'mark_eids' ); " > Check All </ a ></ td >
2002-10-17 06:12:32 +08:00
</ tr >
2002-10-22 21:56:37 +08:00
< tr >< td colspan = " 3 " class = " text " >& nbsp ; </ td ></ tr >
2003-04-11 23:42:54 +08:00
< tr >< td colspan = " 3 " >< table border = " 0 " cellspacing = " 1 " cellpadding = " 0 " width = " 100% " bgcolor = " #7F7FB2 " >
2003-01-07 22:44:06 +08:00
< ? php
$count = 0 ;
while ( $row = mysql_fetch_assoc ( $result ) )
{
if ( ( $count ++% EVENT_HEADER_LINES ) == 0 )
{
?>
2003-04-11 23:42:54 +08:00
< tr align = " center " bgcolor = " #FFFFFF " >
2003-01-14 00:39:00 +08:00
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?><?= $sort_parms ?>&sort_field=Id&sort_asc=<?= $sort_field == 'Id'?! $sort_asc :0 ?> " > Id < ? php if ( $sort_field == " Id " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?><?= $sort_parms ?>&sort_field=Name&sort_asc=<?= $sort_field == 'Name'?! $sort_asc :0 ?> " > Name < ? php if ( $sort_field == " Name " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?><?= $sort_parms ?>&sort_field=Time&sort_asc=<?= $sort_field == 'Time'?! $sort_asc :0 ?> " > Time < ? php if ( $sort_field == " Time " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?><?= $sort_parms ?>&sort_field=Secs&sort_asc=<?= $sort_field == 'Secs'?! $sort_asc :0 ?> " > Duration < ? php if ( $sort_field == " Secs " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?><?= $sort_parms ?>&sort_field=Frames&sort_asc=<?= $sort_field == 'Frames'?! $sort_asc :0 ?> " > Frames < ? php if ( $sort_field == " Frames " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?><?= $sort_parms ?>&sort_field=AlarmFrames&sort_asc=<?= $sort_field == 'AlarmFrames'?! $sort_asc :0 ?> " > Alarm < br > Frames < ? php if ( $sort_field == " AlarmFrames " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?><?= $sort_parms ?>&sort_field=TotScore&sort_asc=<?= $sort_field == 'TotScore'?! $sort_asc :0 ?> " > Total < br > Score < ? php if ( $sort_field == " TotScore " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?><?= $sort_parms ?>&sort_field=AvgScore&sort_asc=<?= $sort_field == 'AvgScore'?! $sort_asc :0 ?> " > Avg .< br > Score < ? php if ( $sort_field == " AvgScore " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
< td class = " text " >< a href = " <?= $PHP_SELF ?>?view=events&mid=<?= $mid ?><?= $filter_query ?><?= $sort_parms ?>&sort_field=MaxScore&sort_asc=<?= $sort_field == 'MaxScore'?! $sort_asc :0 ?> " > Max .< br > Score < ? php if ( $sort_field == " MaxScore " ) if ( $sort_asc ) echo " (^) " ; else echo " (v) " ; ?> </a></td>
2002-10-30 06:03:12 +08:00
< td class = " text " > Mark </ td >
2002-10-17 06:12:32 +08:00
</ tr >
< ? php
2003-01-07 22:44:06 +08:00
}
2002-11-07 20:23:54 +08:00
if ( $row [ LearnState ] == '+' )
$bgcolor = " #98FB98 " ;
elseif ( $row [ LearnState ] == '-' )
$bgcolor = " #FFC0CB " ;
else
unset ( $bgcolor );
2002-10-17 06:12:32 +08:00
?>
2003-04-11 23:42:54 +08:00
< tr < ? = ' bgcolor="' . ( $bgcolor ? $bgcolor : " #FFFFFF " ) . '"' ?> >
2003-04-07 19:38:23 +08:00
< td align = " center " class = " text " >< a href = " javascript: eventWindow( '<?= $PHP_SELF ?>?view=event&mid=<?= $mid ?>&eid=<?= $row[Id] ?>', 'zmEvent' ); " >< span class = " <?= $textclass ?> " >< ? = " $row[Id] " ?> <?php if ( $row[Archived] ) echo "*" ?></span></a></td>
< td align = " center " class = " text " >< a href = " javascript: eventWindow( '<?= $PHP_SELF ?>?view=event&mid=<?= $mid ?>&eid=<?= $row[Id] ?>', 'zmEvent' ); " >< span class = " <?= $textclass ?> " >< ? = " $row[Name] " ?> <?php if ( $row[Archived] ) echo "*" ?></span></a></td>
2003-04-07 21:45:09 +08:00
< td align = " center " class = " text " >< ? = strftime ( " %m/%d %H:%M:%S " , strtotime ( $row [ StartTime ]) ) ?> </td>
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< ? = $row [ Length ] ?> </td>
< td align = " center " class = " text " >< ? = $row [ Frames ] ?> </td>
< td align = " center " class = " text " >< ? = $row [ AlarmFrames ] ?> </td>
< td align = " center " class = " text " >< ? = $row [ TotScore ] ?> </td>
< td align = " center " class = " text " >< ? = $row [ AvgScore ] ?> </td>
< td align = " center " class = " text " >< ? = $row [ MaxScore ] ?> </td>
< td align = " center " class = " text " >< input type = " checkbox " name = " mark_eids[] " value = " <?= $row[Id] ?> " onClick = " configureButton( event_form, 'mark_eids' ); " ></ td >
2002-10-17 06:12:32 +08:00
</ tr >
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-17 06:12:32 +08:00
?>
</ table ></ td ></ tr >
</ table ></ td >
</ tr >
2003-01-04 20:38:26 +08:00
< tr >< td align = " right " >< ? php if ( LEARN_MODE ) { ?> <select name="learn_state" class="form" disabled><option value="">Ignore</option><option value="-">Exclude</option><option value="+">Include</option></select> <input type="button" name="learn_btn" value="Set Learn Prefs" class="form" onClick="event_form.action.value = 'learn'; event_form.submit();" disabled> <?php } ?><input type="button" name="delete_btn" value="Delete" class="form" onClick="event_form.action.value = 'delete'; event_form.submit();" disabled></td></tr>
2002-10-22 21:56:37 +08:00
</ table ></ center >
</ form >
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
2002-10-22 21:56:37 +08:00
}
2002-10-28 04:25:27 +08:00
case " filter " :
{
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
2002-11-29 19:21:37 +08:00
$select_name = " filter_name " ;
$filter_names = array ( '' => 'Choose Filter' );
$result = mysql_query ( " select * from Filters where MonitorId = ' $mid ' order by Name " );
if ( ! $result )
die ( mysql_error () );
while ( $row = mysql_fetch_assoc ( $result ) )
{
$filter_names [ $row [ Name ]] = $row [ Name ];
if ( $filter_name == $row [ Name ] )
{
$filter_data = $row ;
}
}
if ( $filter_data )
{
//$filter_query = unserialize( $filter_data[Query] );
//if ( is_array($filter_query) )
//{
//while( list( $key, $value ) = each( $filter_query ) )
//{
//$$key = $value;
//}
//}
foreach ( split ( '&' , $filter_data [ Query ] ) as $filter_parm )
{
list ( $key , $value ) = split ( '=' , $filter_parm , 2 );
if ( $key )
{
$$key = $value ;
}
}
}
2002-10-28 04:25:27 +08:00
$conjunction_types = array ( 'and' => 'and' , 'or' => 'or' );
$obracket_types = array ( '' => '' );
$cbracket_types = array ( '' => '' );
for ( $i = 1 ; $i <= ceil (( $trms - 1 ) / 2 ); $i ++ )
{
$obracket_types [ $i ] = str_repeat ( " ( " , $i );
$cbracket_types [ $i ] = str_repeat ( " ) " , $i );
}
2003-01-07 22:33:46 +08:00
$attr_types = array ( 'DateTime' => 'Date/Time' , 'Date' => 'Date' , 'Time' => 'Time' , 'Weekday' => 'Weekday' , 'Length' => 'Duration' , 'Frames' => 'Frames' , 'AlarmFrames' => 'Alarm Frames' , 'TotScore' => 'Total Score' , 'AvgScore' => 'Avg. Score' , 'MaxScore' => 'Max. Score' , 'Archived' => 'Archive Status' );
2002-10-28 04:25:27 +08:00
$op_types = array ( '=' => 'equal to' , '!=' => 'not equal to' , '>=' => 'greater than or equal to' , '>' => 'greater than' , '<' => 'less than' , '<=' => 'less than or equal to' );
$archive_types = array ( '0' => 'Unarchived Only' , '1' => 'Archived Only' );
2002-10-22 21:56:37 +08:00
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - < ? = $monitor [ Name ] ?> - Event Filter</title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-22 21:56:37 +08:00
< script language = " JavaScript " >
2002-11-07 20:23:54 +08:00
function newWindow ( Url , Name , Width , Height )
{
var Name = window . open ( Url , Name , " resizable,scrollbars,width= " + Width + " ,height= " + Height );
}
2002-10-22 21:56:37 +08:00
function closeWindow ()
{
top . window . close ();
}
function validateForm ( form )
{
< ? php
2002-10-28 04:25:27 +08:00
if ( $trms > 2 )
{
2002-10-22 21:56:37 +08:00
?>
var bracket_count = 0 ;
< ? php
2002-10-28 04:25:27 +08:00
for ( $i = 1 ; $i <= $trms ; $i ++ )
{
2002-10-22 21:56:37 +08:00
?>
2003-01-14 00:39:00 +08:00
bracket_count += form . obr < ? = $i ?> .value;
bracket_count -= form . cbr < ? = $i ?> .value;
2002-10-22 21:56:37 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-22 21:56:37 +08:00
?>
if ( bracket_count )
{
alert ( " Error, please check you have an equal number of opening and closing brackets " );
return ( false );
}
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-22 21:56:37 +08:00
?>
< ? php
2002-10-28 04:25:27 +08:00
for ( $i = 1 ; $i <= $trms ; $i ++ )
{
2002-10-22 21:56:37 +08:00
?>
2003-01-14 00:39:00 +08:00
if ( form . val < ? = $i ?> .value == '' )
2002-10-22 21:56:37 +08:00
{
alert ( " Error, please check that all terms have a valid value " );
return ( false );
}
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-22 21:56:37 +08:00
?>
return ( true );
}
function submitToFilter ( form )
{
form . target = window . name ;
form . view . value = 'filter' ;
form . submit ();
}
function submitToEvents ( form )
{
2003-01-14 00:39:00 +08:00
var Url = '<?= $PHP_SELF ?>' ;
var Name = 'zmEvents<?= $monitor[Name] ?>' ;
var Width = < ? = $jws [ 'events' ][ 'w' ] ?> ;
var Height = < ? = $jws [ 'events' ][ 'h' ] ?> ;
2002-11-07 20:23:54 +08:00
var Options = 'resizable,scrollbars,width=' + Width + ',height=' + Height ;
window . open ( Url , Name , Options );
form . target = Name ;
2002-10-22 21:56:37 +08:00
form . view . value = 'events' ;
form . submit ();
}
2002-11-28 00:21:49 +08:00
function saveFilter ( form )
{
2003-01-14 00:39:00 +08:00
var Url = '<?= $PHP_SELF ?>' ;
2002-11-28 00:21:49 +08:00
var Name = 'zmEventsFilterSave' ;
2003-01-14 00:39:00 +08:00
var Width = < ? = $jws [ 'filtersave' ][ 'w' ] ?> ;
var Height = < ? = $jws [ 'filtersave' ][ 'h' ] ?> ;
2002-11-28 00:21:49 +08:00
var Options = 'resizable,scrollbars,width=' + Width + ',height=' + Height ;
window . open ( Url , Name , Options );
form . target = Name ;
form . view . value = 'filtersave' ;
form . submit ();
}
function deleteFilter ( form , name , id )
{
if ( confirm ( " Delete saved filter ' " + name + " ' " ) )
{
form . action . value = 'delete' ;
form . fid . value = name ;
submitToFilter ( form );
}
}
2002-10-30 23:37:16 +08:00
window . focus ();
2002-10-22 21:56:37 +08:00
</ script >
</ head >
< body >
2003-01-14 00:39:00 +08:00
< form name = " filter_form " method = " get " action = " <?= $PHP_SELF ?> " >
2002-10-22 21:56:37 +08:00
< input type = " hidden " name = " view " value = " filter " >
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " mid " value = " <?= $mid ?> " >
2002-11-28 00:21:49 +08:00
< input type = " hidden " name = " action " value = " " >
< input type = " hidden " name = " fid " value = " " >
2002-10-22 21:56:37 +08:00
< center >< table width = " 96% " align = " center " border = " 0 " cellspacing = " 1 " cellpadding = " 0 " >
< tr >
< td valign = " top " >< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tr >
2003-01-14 00:39:00 +08:00
< td align = " left " class = " text " > Use & nbsp ; < select name = " trms " class = " form " onChange = " submitToFilter( filter_form ); " >< ? php for ( $i = 0 ; $i <= 8 ; $i ++ ) { ?> <option value="<?= $i ?>"<?php if ( $i == $trms ) { echo " selected"; } ?>><?= $i ?></option><?php } ?></select> filter expressions</td>
2002-11-28 00:21:49 +08:00
< td align = " center " class = " text " > Use filter :& nbsp ; < ? php if ( count ( $filter_names ) > 1 ) { buildSelect ( $select_name , $filter_names , " submitToFilter( filter_form ); " ); } else { ?> <select class="form" disabled><option>No Saved Filters</option></select><?php } ?></td>
< td align = " center " class = " text " >< a href = " javascript: saveFilter( filter_form ); " > Save </ a ></ td >
< ? php if ( $filter_data ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< a href = " javascript: deleteFilter( filter_form, '<?= $filter_data[Name] ?>', <?= $filter_data[Id] ?> ); " > Delete </ a ></ td >
2002-11-28 00:21:49 +08:00
< ? php } else { ?>
< td align = " center " class = " text " >& nbsp ; </ a ></ td >
< ? php } ?>
2002-10-22 21:56:37 +08:00
< td align = " right " class = " text " >< a href = " javascript: closeWindow(); " > Close </ a ></ td >
</ tr >
< tr >
2002-11-28 00:21:49 +08:00
< td colspan = " 5 " class = " text " >& nbsp ; </ td >
2002-10-22 21:56:37 +08:00
</ tr >
< tr >
2002-11-28 00:21:49 +08:00
< td colspan = " 5 " >
2002-10-22 21:56:37 +08:00
< table width = " 100% " border = " 0 " cellspacing = " 0 " cellpadding = " 0 " >
< ? php
2002-10-28 04:25:27 +08:00
for ( $i = 1 ; $i <= $trms ; $i ++ )
{
$conjunction_name = " cnj $i " ;
$obracket_name = " obr $i " ;
$cbracket_name = " cbr $i " ;
$attr_name = " attr $i " ;
$op_name = " op $i " ;
$value_name = " val $i " ;
2002-10-22 21:56:37 +08:00
?>
< tr >
< ? php
2002-10-28 04:25:27 +08:00
if ( $i == 1 )
{
2002-10-22 21:56:37 +08:00
?>
< td class = " text " >& nbsp ; </ td >
< ? php
2002-10-28 04:25:27 +08:00
}
else
{
2002-10-22 21:56:37 +08:00
?>
< td class = " text " >< ? php buildSelect ( $conjunction_name , $conjunction_types ); ?> </td>
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-22 21:56:37 +08:00
?>
< td class = " text " >< ? php if ( $trms > 2 ) { buildSelect ( $obracket_name , $obracket_types ); } else { ?> <?php } ?></td>
< td class = " text " >< ? php buildSelect ( $attr_name , $attr_types , " $value_name .value = ''; submitToFilter( filter_form ); " ); ?> </td>
< ? php if ( $$attr_name == " Archived " ) { ?>
< td class = " text " >< center > is equal to </ center ></ td >
< td class = " text " >< ? php buildSelect ( $value_name , $archive_types ); ?> </td>
< ? php } elseif ( $$attr_name ) { ?>
< td class = " text " >< ? php buildSelect ( $op_name , $op_types ); ?> </td>
2003-01-14 00:39:00 +08:00
< td class = " text " >< input name = " <?= $value_name ?> " value = " <?= $ $value_name ?> " class = " form " size = " 16 " ></ td >
2002-10-22 21:56:37 +08:00
< ? php } else { ?>
< td class = " text " >< ? php buildSelect ( $op_name , $op_types ); ?> </td>
2003-01-14 00:39:00 +08:00
< td class = " text " >< input name = " <?= $value_name ?> " value = " <?= $ $value_name ?> " class = " form " size = " 16 " ></ td >
2002-10-22 21:56:37 +08:00
< ? php } ?>
< td class = " text " >< ? php if ( $trms > 2 ) { buildSelect ( $cbracket_name , $cbracket_types ); } else { ?> <?php } ?></td>
</ tr >
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-22 21:56:37 +08:00
?>
</ table >
</ td >
</ tr >
2002-11-28 00:21:49 +08:00
< tr >< td colspan = " 5 " class = " text " >& nbsp ; </ td ></ tr >
< tr >< td colspan = " 5 " align = " right " >< input type = " reset " value = " Reset " class = " form " >& nbsp ; & nbsp ; < input type = " button " value = " Submit " class = " form " onClick = " if ( validateForm( filter_form ) ) submitToEvents( filter_form ); " ></ td ></ tr >
</ table ></ center >
</ form >
</ body >
</ html >
< ? php
break ;
}
case " filtersave " :
{
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - < ? = $monitor [ Name ] ?> - Save Filter</title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-11-28 00:21:49 +08:00
< script language = " JavaScript " >
function closeWindow ()
{
top . window . close ();
}
function validateForm ( form )
{
return ( true );
}
window . focus ();
</ script >
</ head >
< body >
2003-01-14 00:39:00 +08:00
< form name = " filter_form " method = " get " action = " <?= $PHP_SELF ?> " onSubmit = " validateForm( this ); " >
2002-11-28 00:21:49 +08:00
< input type = " hidden " name = " view " value = " none " >
< input type = " hidden " name = " action " value = " filter " >
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " mid " value = " <?= $mid ?> " >
< input type = " hidden " name = " trms " value = " <?= $trms ?> " >
2002-11-28 00:21:49 +08:00
< ? php
for ( $i = 1 ; $i <= $trms ; $i ++ )
{
$conjunction_name = " cnj $i " ;
$obracket_name = " obr $i " ;
$cbracket_name = " cbr $i " ;
$attr_name = " attr $i " ;
$op_name = " op $i " ;
$value_name = " val $i " ;
if ( $i > 1 )
{
?>
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " <?= $conjunction_name ?> " value = " <?= $ $conjunction_name ?> " >
2002-11-28 00:21:49 +08:00
< ? php
}
?>
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " <?= $obracket_name ?> " value = " <?= $ $obracket_name ?> " >
< input type = " hidden " name = " <?= $cbracket_name ?> " value = " <?= $ $cbracket_name ?> " >
< input type = " hidden " name = " <?= $attr_name ?> " value = " <?= $ $attr_name ?> " >
< input type = " hidden " name = " <?= $op_name ?> " value = " <?= $ $op_name ?> " >
< input type = " hidden " name = " <?= $value_name ?> " value = " <?= $ $value_name ?> " >
2002-11-28 00:21:49 +08:00
< ? php
}
?>
< center >< table width = " 96% " align = " center " border = " 0 " cellspacing = " 1 " cellpadding = " 0 " >
< tr >
< ? php
$select_name = " filter_name " ;
$result = mysql_query ( " select * from Filters where MonitorId = ' $mid ' order by Name " );
if ( ! $result )
die ( mysql_error () );
while ( $row = mysql_fetch_assoc ( $result ) )
{
$filter_names [ $row [ Name ]] = $row [ Name ];
if ( $filter_name == $row [ Name ] )
{
$filter_data = $row ;
}
}
?>
< ? php if ( count ( $filter_names ) ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " left " colspan = " 2 " class = " text " > Save as :& nbsp ; < ? php buildSelect ( $select_name , $filter_names , " submitToFilter( filter_form ); " ); ?> or enter new name: <input type="text" size="32" name="new_<?= $select_name ?>" value="<?= $filter ?>" class="form"></td>
2002-11-28 00:21:49 +08:00
< ? php } else { ?>
2003-01-14 00:39:00 +08:00
< td align = " left " colspan = " 2 " class = " text " > Enter new filter name :& nbsp ; < input type = " text " size = " 32 " name = " new_<?= $select_name ?> " value = " " class = " form " ></ td >
2002-11-28 00:21:49 +08:00
< ? php } ?>
</ tr >
< tr >
2002-11-29 19:24:45 +08:00
< td align = " right " colspan = " 2 " class = " text " >& nbsp ; </ td >
</ tr >
< tr >
2003-01-15 18:05:26 +08:00
< td align = " left " class = " text " > Automatically delete all matching events :& nbsp ; </ td >
< td align = " left " class = " text " >< input type = " checkbox " name = " auto_delete " value = " 1 " < ? php if ( $filter_data [ AutoDelete ] ) { echo " checked " ; } ?> ></td>
</ tr >
< tr >
2002-11-29 19:23:17 +08:00
< td align = " left " class = " text " > Automatically upload all matching events :& nbsp ; </ td >
< td align = " left " class = " text " >< input type = " checkbox " name = " auto_upload " value = " 1 " < ? php if ( $filter_data [ AutoUpload ] ) { echo " checked " ; } ?> ></td>
</ tr >
< tr >
2003-01-15 18:05:26 +08:00
< td align = " left " class = " text " > Automatically email details of all matching events :& nbsp ; </ td >
< td align = " left " class = " text " >< input type = " checkbox " name = " auto_email " value = " 1 " < ? php if ( $filter_data [ AutoEmail ] ) { echo " checked " ; } ?> ></td>
</ tr >
< tr >
< td align = " left " class = " text " > Automatically message details of all matching events :& nbsp ; </ td >
< td align = " left " class = " text " >< input type = " checkbox " name = " auto_message " value = " 1 " < ? php if ( $filter_data [ AutoMessage ] ) { echo " checked " ; } ?> ></td>
2002-11-28 00:21:49 +08:00
</ tr >
< tr >
< td align = " right " colspan = " 2 " class = " text " >& nbsp ; </ td >
</ tr >
2002-10-22 21:56:37 +08:00
< tr >
2002-11-28 00:21:49 +08:00
< td align = " right " colspan = " 2 " class = " text " >< input type = " submit " value = " Save " class = " form " >& nbsp ; < input type = " button " value = " Cancel " class = " form " onClick = " closeWindow(); " ></ td >
2002-10-22 21:56:37 +08:00
</ tr >
2002-10-17 06:12:32 +08:00
</ table ></ center >
</ form >
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
}
case " image " :
{
$result = mysql_query ( " select E.*,M.Name as MonitorName,M.Width,M.Height from Events as E, Monitors as M where E.Id = ' $eid ' and E.MonitorId = M.Id " );
if ( ! $result )
die ( mysql_error () );
$event = mysql_fetch_assoc ( $result );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$result = mysql_query ( " select * from Frames where EventID = ' $eid ' and FrameId = ' $fid ' " );
if ( ! $result )
die ( mysql_error () );
$frame = mysql_fetch_assoc ( $result );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$result = mysql_query ( " select count(*) as FrameCount from Frames where EventID = ' $eid ' " );
if ( ! $result )
die ( mysql_error () );
$row = mysql_fetch_assoc ( $result );
$max_fid = $row [ FrameCount ];
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$first_fid = 1 ;
$prev_fid = $fid - 1 ;
$next_fid = $fid + 1 ;
$last_fid = $max_fid ;
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$image_path = $frame [ ImagePath ];
$anal_image = preg_replace ( " /capture/ " , " analyse " , $image_path );
if ( file_exists ( $anal_image ) )
{
$image_path = $anal_image ;
}
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - Image < ? = $eid . " - " . $fid ?> </title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
window . focus ();
2002-10-22 21:56:37 +08:00
function newWindow ( Url , Name , Width , Height )
{
2002-10-11 17:45:06 +08:00
var Name = window . open ( Url , Name , " resizable,scrollbars,width= " + Width + " ,height= " + Height );
}
2002-10-22 21:56:37 +08:00
function closeWindow ()
{
2002-10-11 17:45:06 +08:00
window . close ();
}
2002-10-22 21:56:37 +08:00
function deleteEvent ()
{
2003-01-14 00:39:00 +08:00
opener . location . href = " <?= $PHP_SELF ?>?view=none&action=delete&mark_eid=<?= $eid ?> " ;
2002-10-11 17:45:06 +08:00
window . close ();
}
</ script >
</ head >
< body >
< table border = " 0 " >
2003-04-11 23:42:54 +08:00
< tr >< td colspan = " 2 " class = " smallhead " > Image < ? = $eid . " - " . $fid . " ( $frame[Score] ) " ?>
< ? php if ( ZM_RECORD_EVENT_STATS ) { ?>
( < a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=stats&eid=<?= $eid ?>&fid=<?= $fid ?>', 'zmStats', <?= $jws['stats'] ['w'] ?>, <?= $jws['stats'] ['h'] ?> ); " > Stats </ a > )
< ? php } ?>
</ td >
2002-10-11 17:45:06 +08:00
< td align = " center " class = " text " >< a href = " javascript: deleteEvent(); " > Delete </ a ></ td >
< td align = " right " class = " text " >< a href = " javascript: closeWindow(); " > Close </ a ></ td >
</ tr >
2003-01-14 00:39:00 +08:00
< tr >< td colspan = " 4 " >< img src = " <?= $image_path ?> " width = " <?= $event[Width] ?> " height = " <?= $event[Height] ?> " border = " 0 " ></ td ></ tr >
2002-10-11 17:45:06 +08:00
< tr >
< ? php if ( $fid > 1 ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " center " width = " 25% " class = " text " >< a href = " <?= $PHP_SELF ?>?view=image&eid=<?= $eid ?>&fid=<?= $first_fid ?> " > First </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } else { ?>
< td align = " center " width = " 25% " class = " text " >& nbsp ; </ td >
< ? php } if ( $fid > 1 ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " center " width = " 25% " class = " text " >< a href = " <?= $PHP_SELF ?>?view=image&eid=<?= $eid ?>&fid=<?= $prev_fid ?> " > Prev </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } else { ?>
< td align = " center " width = " 25% " class = " text " >& nbsp ; </ td >
< ? php } if ( $fid < $max_fid ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " center " width = " 25% " class = " text " >< a href = " <?= $PHP_SELF ?>?view=image&eid=<?= $eid ?>&fid=<?= $next_fid ?> " > Next </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } else { ?>
< td align = " center " width = " 25% " class = " text " >& nbsp ; </ td >
< ? php } if ( $fid < $max_fid ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " center " width = " 25% " class = " text " >< a href = " <?= $PHP_SELF ?>?view=image&eid=<?= $eid ?>&fid=<?= $last_fid ?> " > Last </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } else { ?>
< td align = " center " width = " 25% " class = " text " >& nbsp ; </ td >
< ? php } ?>
</ tr >
</ table >
</ body >
</ html >
2003-04-11 23:42:54 +08:00
< ? php
break ;
}
case " stats " :
{
$result = mysql_query ( " select S.*,E.*,Z.Name as ZoneName,M.Name as MonitorName,M.Width,M.Height from Stats as S left join Events as E on S.EventId = E.Id left join Zones as Z on S.ZoneId = Z.Id left join Monitors as M on E.MonitorId = M.Id where S.EventId = ' $eid ' and S.FrameId = ' $fid ' order by S.ZoneId " );
if ( ! $result )
die ( mysql_error () );
while ( $row = mysql_fetch_assoc ( $result ) )
{
$stats [] = $row ;
}
?>
< html >
< head >
< title > ZM - Stats < ? = $eid . " - " . $fid ?> </title>
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
< script language = " JavaScript " >
window . focus ();
function closeWindow ()
{
window . close ();
}
</ script >
</ head >
< body >
< table width = " 96% " border = " 0 " >
< tr >
< td align = " left " class = " smallhead " >< b > Image < ? = $eid . " - " . $fid ?> </b></td>
< td align = " right " class = " text " >< a href = " javascript: closeWindow(); " > Close </ a ></ td >
</ tr >
< tr >< td colspan = " 2 " >< table width = " 100% " border = " 0 " bgcolor = " #7F7FB2 " cellpadding = " 3 " cellspacing = " 1 " >< tr bgcolor = " #FFFFFF " >
< td class = " smallhead " > Zone </ td >
< td class = " smallhead " align = " right " > Alarm Px </ td >
< td class = " smallhead " align = " right " > Filter Px </ td >
< td class = " smallhead " align = " right " > Blob Px </ td >
< td class = " smallhead " align = " right " > Blobs </ td >
< td class = " smallhead " align = " right " > Blob Sizes </ td >
< td class = " smallhead " align = " right " > Alarm Limits </ td >
< td class = " smallhead " align = " right " > Score </ td >
</ tr >
< ? php
if ( count ( $stats ) )
{
foreach ( $stats as $stat )
{
?>
< tr bgcolor = " #FFFFFF " >
< td class = " text " >< ? = $stat [ ZoneName ] ?> </td>
< td class = " text " align = " right " >< ? = $stat [ AlarmPixels ] ?> </td>
< td class = " text " align = " right " >< ? = $stat [ FilterPixels ] ?> </td>
< td class = " text " align = " right " >< ? = $stat [ BlobPixels ] ?> </td>
< td class = " text " align = " right " >< ? = $stat [ Blobs ] ?> </td>
< td class = " text " align = " right " >< ? = $stat [ MinBlobSize ] . " - " . $stat [ MaxBlobSize ] ?> </td>
< td class = " text " align = " right " >< ? = $stat [ MinX ] . " , " . $stat [ MinY ] . " - " . $stat [ MaxX ] . " , " . $stat [ MaxY ] ?> </td>
< td class = " text " align = " right " >< ? = $stat [ Score ] ?> </td>
</ tr >
< ? php
}
}
else
{
?>
< tr bgcolor = " #FFFFFF " >
< td class = " text " colspan = " 8 " align = " center " >< br > There are no statistics recorded for this event / frame < br >< br ></ td >
</ tr >
< ? php
}
?>
</ table ></ td >
</ tr >
</ table >
</ body >
</ html >
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
break ;
2002-10-11 17:45:06 +08:00
}
2002-10-28 04:25:27 +08:00
case " event " :
{
if ( ! $mode )
{
if ( canStream () )
$mode = " stream " ;
else
$mode = " still " ;
}
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$result = mysql_query ( " select E.*,M.Name as MonitorName,M.Width,M.Height from Events as E, Monitors as M where E.Id = ' $eid ' and E.MonitorId = M.Id " );
if ( ! $result )
die ( mysql_error () );
$event = mysql_fetch_assoc ( $result );
2003-04-07 19:38:23 +08:00
$result = mysql_query ( " select * from Events where Id < ' $eid ' and MonitorId = ' $mid ' order by Id desc limit 0,1 " );
if ( ! $result )
die ( mysql_error () );
$prev_event = mysql_fetch_assoc ( $result );
$result = mysql_query ( " select * from Events where Id > ' $eid ' and MonitorId = ' $mid ' order by Id asc limit 0,1 " );
if ( ! $result )
die ( mysql_error () );
$next_event = mysql_fetch_assoc ( $result );
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - Event - < ? = $event [ Name ] ?> </title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
2002-11-07 20:23:54 +08:00
< ? php
if ( $refresh_parent )
{
?>
opener . location . reload ();
< ? php
}
?>
2002-10-11 17:45:06 +08:00
window . focus ();
2002-10-22 21:56:37 +08:00
function refreshWindow ()
{
window . location . reload ();
2002-10-11 17:45:06 +08:00
}
2002-10-22 21:56:37 +08:00
function closeWindow ()
{
window . close ();
2002-10-11 17:45:06 +08:00
}
2002-10-22 21:56:37 +08:00
function newWindow ( Url , Name , Width , Height )
{
var Name = window . open ( Url , Name , " resizable,scrollbars,width= " + Width + " ,height= " + Height );
2002-10-11 17:45:06 +08:00
}
</ script >
</ head >
< body >
< table border = " 0 " cellspacing = " 0 " cellpadding = " 4 " width = " 100% " >
< tr >
2002-11-07 20:23:54 +08:00
< td colspan = " 3 " align = " left " class = " text " >
2003-01-14 00:39:00 +08:00
< form name = " rename_form " method = " get " action = " <?= $PHP_SELF ?> " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
2002-10-11 17:45:06 +08:00
< input type = " hidden " name = " action " value = " rename " >
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " eid " value = " <?= $eid ?> " >
< input type = " text " size = " 16 " name = " event_name " value = " <?= $event[Name] ?> " class = " form " >
2002-11-07 20:23:54 +08:00
< input type = " submit " value = " Rename " class = " form " ></ form ></ td >
< td colspan = " 3 " align = " right " class = " text " >
2003-01-14 00:39:00 +08:00
< form name = " learn_form " method = " get " action = " <?= $PHP_SELF ?> " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
2002-11-07 20:23:54 +08:00
< input type = " hidden " name = " action " value = " learn " >
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " eid " value = " <?= $eid ?> " >
< input type = " hidden " name = " mark_eid " value = " <?= $eid ?> " >
2003-01-04 20:38:26 +08:00
< ? php if ( LEARN_MODE ) { ?>
2002-11-07 20:23:54 +08:00
Learn Pref :& nbsp ; < select name = " learn_state " class = " form " onChange = " learn_form.submit(); " >< option value = " " < ? php if ( ! $event [ LearnState ] ) echo " selected " ?> >Ignore</option><option value="-"<?php if ( $event[LearnState]=='-' ) echo " selected" ?>>Exclude</option><option value="+"<?php if ( $event[LearnState]=='+' ) echo " selected" ?>>Include</option></select>
2003-01-04 20:38:26 +08:00
< ? php } ?>
2002-11-07 20:23:54 +08:00
</ form ></ td >
2002-10-11 17:45:06 +08:00
</ tr >
< tr >
< td align = " center " class = " text " >< a href = " javascript: refreshWindow(); " > Refresh </ a ></ td >
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=none&action=delete&mark_eid=<?= $eid ?> " > Delete </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php if ( $event [ Archived ] ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=<?= $view ?>&action=unarchive&eid=<?= $eid ?> " > Unarchive </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } else { ?>
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=<?= $view ?>&action=archive&eid=<?= $eid ?> " > Archive </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } ?>
< ? php if ( $mode == " stream " ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=event&mode=still&mid=<?= $mid ?>&eid=<?= $eid ?> " > Stills </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } elseif ( canStream () ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< a href = " <?= $PHP_SELF ?>?view=event&mode=stream&mid=<?= $mid ?>&eid=<?= $eid ?> " > Stream </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } else { ?>
< td align = " center " class = " text " >& nbsp ; </ td >
< ? php } ?>
2003-01-11 18:23:39 +08:00
< ? php if ( ZM_OPT_MPEG && file_exists ( ZM_PATH_MPEG_ENCODE ) ) { ?>
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=video&eid=<?= $eid ?>', 'zmVideo', <?= $jws['video'] ['w'] ?>, <?= $jws['video'] ['h'] ?> ); " > Video </ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php } else { ?>
< td align = " center " class = " text " >& nbsp ; </ td >
< ? php } ?>
< td align = " right " class = " text " >< a href = " javascript: closeWindow(); " > Close </ a ></ td >
</ tr >
2002-10-28 04:25:27 +08:00
< ? php
if ( $mode == " stream " )
{
2003-01-15 23:06:15 +08:00
$stream_src = ZMS_PATH . " ?path= " . ZM_PATH_WEB . " &event= $eid &refresh= " . STREAM_EVENT_DELAY ;
2002-10-28 04:25:27 +08:00
if ( isNetscape () )
{
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< tr >< td colspan = " 6 " align = " center " >< img src = " <?= $stream_src ?> " border = " 0 " width = " <?= $event[Width] ?> " height = " <?= $event[Height] ?> " ></ td ></ tr >
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
else
{
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< tr >< td colspan = " 6 " align = " center " >< applet code = " com.charliemouse.cambozola.Viewer " archive = " <?= ZM_PATH_CAMBOZOLA ?> " align = " middle " width = " <?= $event[Width] ?> " height = " <?= $event[Height] ?> " >< param name = " url " value = " <?= $stream_src ?> " ></ applet ></ td ></ tr >
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
}
else
{
$result = mysql_query ( " select * from Frames where EventID = ' $eid ' order by Id " );
if ( ! $result )
die ( mysql_error () );
2002-10-11 17:45:06 +08:00
?>
< tr >< td colspan = " 6 " >< table border = " 0 " cellpadding = " 0 " cellspacing = " 2 " align = " center " >
< tr >
< ? php
2002-10-28 04:25:27 +08:00
$count = 0 ;
$scale = IMAGE_SCALING ;
$fraction = sprintf ( " %.2f " , 1 / $scale );
$thumb_width = $event [ Width ] / 4 ;
$thumb_height = $event [ Height ] / 4 ;
while ( $row = mysql_fetch_assoc ( $result ) )
2002-10-11 17:45:06 +08:00
{
2002-10-28 04:25:27 +08:00
$frame_id = $row [ FrameId ];
$image_path = $row [ ImagePath ];
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$capt_image = $image_path ;
2003-01-11 01:12:23 +08:00
if ( $scale == 1 || ! file_exists ( ZM_PATH_NETPBM . " /jpegtopnm " ) )
2002-10-28 04:25:27 +08:00
{
$anal_image = preg_replace ( " /capture/ " , " analyse " , $image_path );
if ( file_exists ( $anal_image ) && filesize ( $anal_image ) )
{
$thumb_image = $anal_image ;
}
else
{
$thumb_image = $capt_image ;
}
}
2002-10-11 17:45:06 +08:00
else
2002-10-28 04:25:27 +08:00
{
$thumb_image = preg_replace ( " /capture/ " , " thumb " , $capt_image );
if ( ! file_exists ( $thumb_image ) || ! filesize ( $thumb_image ) )
{
$anal_image = preg_replace ( " /capture/ " , " analyse " , $capt_image );
if ( file_exists ( $anal_image ) )
2003-01-11 01:12:23 +08:00
$command = ZM_PATH_NETPBM . " /jpegtopnm -dct fast $anal_image | " . ZM_PATH_NETPBM . " /pnmscalefixed $fraction | " . ZM_PATH_NETPBM . " /ppmtojpeg --dct=fast > $thumb_image " ;
2002-10-28 04:25:27 +08:00
else
2003-01-11 01:12:23 +08:00
$command = ZM_PATH_NETPBM . " /jpegtopnm -dct fast $capt_image | " . ZM_PATH_NETPBM . " /pnmscalefixed $fraction | " . ZM_PATH_NETPBM . " /ppmtojpeg --dct=fast > $thumb_image " ;
2002-10-28 04:25:27 +08:00
#exec( escapeshellcmd( $command ) );
exec ( $command );
}
}
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< td align = " center " width = " 88 " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=image&eid=<?= $eid ?>&fid=<?= $frame_id ?>', 'zmImage', <?= $event[Width] + $jws['image'] ['w'] ?>, <?= $event[Height] + $jws['image'] ['h'] ?> ); " >< img src = " <?= $thumb_image ?> " width = " <?= $thumb_width ?> " height = " <? echo $thumb_height ?> " border = " 0 " alt = " <?= $frame_id ?>/<?= $row[Score] ?> " ></ a ></ td >
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
flush ();
if ( ! ( ++ $count % 4 ) )
{
2002-10-11 17:45:06 +08:00
?>
</ tr >
< tr >
< ? php
2002-10-28 04:25:27 +08:00
}
}
2002-10-11 17:45:06 +08:00
?>
</ tr >
</ table ></ td ></ tr >
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
2003-04-07 19:38:23 +08:00
< tr >
< td colspan = " 6 " >< table width = " 100% " cellpadding = " 0 " cellspacing = " 0 " border = " 0 " >< tr >
< td width = " 25% " align = " center " class = " text " >< ? php if ( $prev_event ) { ?> <a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&mid=<?= $mid ?>&eid=<?= $prev_event[Id] ?>">Prev</a><?php } else { ?> <?php } ?></td>
< td width = " 25% " align = " center " class = " text " >< ? php if ( $prev_event ) { ?> <a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&mid=<?= $mid ?>&eid=<?= $prev_event[Id] ?>&action=delete&mark_eid=<?= $eid ?>">Delete & Prev</a><?php } else { ?> <?php } ?></td>
< td width = " 25% " align = " center " class = " text " >< ? php if ( $next_event ) { ?> <a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&mid=<?= $mid ?>&eid=<?= $next_event[Id] ?>&action=delete&mark_eid=<?= $eid ?>">Delete & Next</a><?php } else { ?> <?php } ?></td>
< td width = " 25% " align = " center " class = " text " >< ? php if ( $next_event ) { ?> <a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mode=<?= $mode ?>&mid=<?= $mid ?>&eid=<?= $next_event[Id] ?>">Next</a><?php } else { ?> <?php } ?></td>
</ tr ></ table ></ td >
</ tr >
2002-10-11 17:45:06 +08:00
</ table >
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
}
case " zones " :
{
2003-01-11 06:29:02 +08:00
chdir ( ZM_DIR_IMAGES );
2002-10-28 04:25:27 +08:00
$status = exec ( escapeshellcmd ( ZMU_PATH . " -m $mid -z " ) );
2003-01-04 00:37:17 +08:00
chdir ( '..' );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$result = mysql_query ( " select * from Zones where MonitorId = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$zones = array ();
while ( $row = mysql_fetch_assoc ( $result ) )
{
$zones [] = $row ;
}
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
$image = $monitor [ Name ] . " -Zones.jpg " ;
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - < ? = $monitor [ Name ] ?> - Zones</title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
window . focus ();
2002-10-22 21:56:37 +08:00
function newWindow ( Url , Name , Width , Height )
{
var Name = window . open ( Url , Name , " resizable,scrollbars,width= " + Width + " ,height= " + Height );
2002-10-11 17:45:06 +08:00
}
2002-10-22 21:56:37 +08:00
function closeWindow ()
{
window . close ();
2002-10-11 17:45:06 +08:00
}
2002-10-30 06:03:12 +08:00
function configureButton ( form , name )
{
var checked = false ;
for ( var i = 0 ; i < form . elements . length ; i ++ )
{
if ( form . elements [ i ] . name . indexOf ( name ) == 0 )
{
if ( form . elements [ i ] . checked )
{
checked = true ;
break ;
}
}
}
form . delete_btn . disabled = ! checked ;
}
2002-10-11 17:45:06 +08:00
</ script >
</ head >
< body >
< map name = " zonemap " >
< ? php
2002-10-28 04:25:27 +08:00
foreach ( $zones as $zone )
{
2003-04-07 22:06:25 +08:00
if ( $zone [ Units ] == 'Percent' )
{
?>
< area shape = " rect " coords = " <?= sprintf( " % d , % d , % d , % d " , $zone[LoX] * $monitor[Width] , $zone[LoY] * $monitor[Height] , $zone[HiX] * $monitor[Width] , $zone[HiY] * $monitor[Height] ) ?> " href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=zone&mid=<?= $mid ?>&zid=<?= $zone[Id] ?>', 'zmZone', <?= $jws['zone'] ['w'] ?>, <?= $jws['zone'] ['h'] ?> ); " >
< ? php
}
else
{
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< area shape = " rect " coords = " <?= " $zone [ LoX ], $zone [ LoY ], $zone [ HiX ], $zone [ HiY ] " ?> " href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=zone&mid=<?= $mid ?>&zid=<?= $zone[Id] ?>', 'zmZone', <?= $jws['zone'] ['w'] ?>, <?= $jws['zone'] ['h'] ?> ); " >
2002-10-11 17:45:06 +08:00
< ? php
2003-04-07 22:06:25 +08:00
}
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
< area shape = " default " nohref >
</ map >
< table align = " center " border = " 0 " cellspacing = " 2 " cellpadding = " 2 " width = " 96% " >
< tr >
< td width = " 33% " align = " left " class = " text " >& nbsp ; </ td >
2003-01-14 00:39:00 +08:00
< td width = " 34% " align = " center " class = " head " >< strong >< ? = $monitor [ Name ] ?> Zones</strong></td>
2002-10-11 17:45:06 +08:00
< td width = " 33% " align = " right " class = " text " >< a href = " javascript: closeWindow(); " > Close </ a ></ td >
</ tr >
2003-01-14 00:39:00 +08:00
< tr >< td colspan = " 3 " align = " center " >< img src = " <?= ZM_DIR_IMAGES.'/'. $image ?> " usemap = " #zonemap " width = " <?= $monitor[Width] ?> " height = " <?= $monitor[Height] ?> " border = " 0 " ></ td ></ tr >
2002-10-11 17:45:06 +08:00
</ table >
< table align = " center " border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 96% " >
2003-01-14 00:39:00 +08:00
< form name = " zone_form " method = " get " action = " <?= $PHP_SELF ?> " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
2002-10-11 17:45:06 +08:00
< input type = " hidden " name = " action " value = " delete " >
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " mid " value = " <?= $mid ?> " >
2002-10-11 17:45:06 +08:00
< tr >< td align = " center " class = " smallhead " > Id </ td >
< td align = " center " class = " smallhead " > Name </ td >
< td align = " center " class = " smallhead " > Type </ td >
< td align = " center " class = " smallhead " > Units </ td >
< td align = " center " class = " smallhead " > Dimensions </ td >
2002-10-30 06:03:12 +08:00
< td align = " center " class = " smallhead " > Mark </ td >
2002-10-11 17:45:06 +08:00
</ tr >
< ? php
2002-10-28 04:25:27 +08:00
foreach ( $zones as $zone )
{
2002-10-11 17:45:06 +08:00
?>
< tr >
2003-01-14 00:39:00 +08:00
< td align = " center " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=zone&mid=<?= $mid ?>&zid=<?= $zone[Id] ?>', 'zmZone', <?= $jws['zone'] ['w'] ?>, <?= $jws['zone'] ['h'] ?> ); " >< ? = $zone [ Id ] ?> .</a></td>
< td align = " center " class = " text " >< a href = " javascript: newWindow( '<?= $PHP_SELF ?>?view=zone&mid=<?= $mid ?>&zid=<?= $zone[Id] ?>', 'zmZone', <?= $jws['zone'] ['w'] ?>, <?= $jws['zone'] ['h'] ?> ); " >< ? = $zone [ Name ] ?> </a></td>
< td align = " center " class = " text " >< ? = $zone [ 'Type' ] ?> </td>
< td align = " center " class = " text " >< ? = $zone [ Units ] ?> </td>
< td align = " center " class = " text " >< ? = $zone [ LoX ] ?> ,<?= $zone[LoY] ?>-<?= $zone[HiX] ?>,<?= $zone[HiY]?></td>
< td align = " center " class = " text " >< input type = " checkbox " name = " mark_zids[] " value = " <?= $zone[Id] ?> " onClick = " configureButton( zone_form, 'mark_zids' ); " ></ td >
2002-10-11 17:45:06 +08:00
</ tr >
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
< tr >
< td align = " center " class = " text " >& nbsp ; </ td >
2003-01-14 00:39:00 +08:00
< td colspan = " 4 " align = " center " >< input type = " button " value = " Add New Zone " class = " form " onClick = " javascript: newWindow( '<?= $PHP_SELF ?>?view=zone&mid=<?= $mid ?>&zid=-1', 'zmZone', <?= $jws['zone'] ['w'] ?>, <?= $jws['zone'] ['h'] ?> ); " ></ td >
2002-10-30 06:03:12 +08:00
< td align = " center " >< input type = " submit " name = " delete_btn " value = " Delete " class = " form " disabled ></ td >
2002-10-11 17:45:06 +08:00
</ tr >
</ form >
</ table >
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
2002-10-11 17:45:06 +08:00
}
2002-10-28 04:25:27 +08:00
case " monitor " :
2002-10-11 17:45:06 +08:00
{
2002-10-28 04:25:27 +08:00
if ( $mid > 0 )
{
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
}
else
{
$monitor = array ();
$monitor [ Name ] = " New " ;
2003-03-26 19:41:22 +08:00
$monitor [ 'Function' ] = " None " ;
$monitor [ Type ] = " Local " ;
$monitor [ Port ] = " 80 " ;
2003-01-12 02:24:42 +08:00
$monitor [ LabelFormat ] = '%%s - %y/%m/%d %H:%M:%S' ;
2003-01-12 02:20:19 +08:00
$monitor [ LabelX ] = 0 ;
2003-01-12 02:24:42 +08:00
$monitor [ LabelY ] = 0 ;
2003-01-12 02:20:19 +08:00
$monitor [ ImageBufferCount ] = 100 ;
$monitor [ WarmupCount ] = 25 ;
$monitor [ PreEventCount ] = 10 ;
$monitor [ PostEventCount ] = 10 ;
2003-03-27 06:12:25 +08:00
$monitor [ MaxFPS ] = 0 ;
2003-01-12 02:20:19 +08:00
$monitor [ FPSReportInterval ] = 1000 ;
$monitor [ RefBlendPerc ] = 10 ;
}
2003-04-13 01:18:52 +08:00
$local_palettes = array ( " Grey " => 1 , " RGB24 " => 4 , " RGB565 " => 3 , " YUV420P " => 15 );
2003-04-13 00:17:17 +08:00
$remote_palettes = array ( " 8 bit greyscale " => 1 , " 24 bit colour " => 4 );
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - Monitor < ? = $monitor [ Name ] ?> </title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
< ? php
2002-10-28 04:25:27 +08:00
if ( $refresh_parent )
{
2002-10-11 17:45:06 +08:00
?>
opener . location . reload ();
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
window . focus ();
function validateForm ( theForm )
{
return ( true );
}
2002-10-22 21:56:37 +08:00
function closeWindow ()
{
window . close ();
2002-10-11 17:45:06 +08:00
}
</ script >
</ head >
< body >
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tr >
2003-01-14 00:39:00 +08:00
< td colspan = " 2 " align = " left " class = " head " > Monitor < ? = $monitor [ Name ] ?> </td>
2002-10-11 17:45:06 +08:00
</ tr >
2003-01-14 00:39:00 +08:00
< form name = " monitorForm " method = " get " action = " <?= $PHP_SELF ?> " onsubmit = " return validateForm(this) " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
2003-03-26 19:41:22 +08:00
< input type = " hidden " name = " action " value = " " >
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " mid " value = " <?= $mid ?> " >
2002-10-11 17:45:06 +08:00
< tr >
< td align = " left " class = " smallhead " > Parameter </ td >< td align = " left " class = " smallhead " > Value </ td >
</ tr >
2003-01-14 00:39:00 +08:00
< tr >< td align = " left " class = " text " > Name </ td >< td align = " left " class = " text " >< input type = " text " name = " new_name " value = " <?= $monitor[Name] ?> " size = " 12 " class = " form " ></ td ></ tr >
2002-10-11 17:45:06 +08:00
< tr >< td align = " left " class = " text " > Function </ td >< td align = " left " class = " text " >< select name = " new_function " class = " form " >
< ? php
2002-10-28 04:25:27 +08:00
foreach ( getEnumValues ( 'Monitors' , 'Function' ) as $opt_function )
{
2003-01-11 01:12:23 +08:00
if ( ! ZM_OPT_X10 && $opt_function == 'X10' )
2003-01-02 19:59:52 +08:00
continue ;
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< option value = " <?= $opt_function ?> " < ? php if ( $opt_function == $monitor [ 'Function' ] ) { ?> selected<?php } ?>><?= $opt_function ?></option>
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
</ select ></ td ></ tr >
2003-03-26 19:41:22 +08:00
< ? php
$select_name = " new_type " ;
$$select_name = $$select_name ? $$select_name : $monitor [ Type ];
$source_types = array ( " Local " => " Local " , " Remote " => " Remote " );
?>
< tr >< td align = " left " class = " text " > Source Type </ td >< td >< ? php buildSelect ( $select_name , $source_types , " monitorForm.submit(); " ); ?> </td></tr>
< ? php
if ( $$select_name == " Local " )
{
?>
2003-01-14 00:39:00 +08:00
< tr >< td align = " left " class = " text " > Device Number ( / dev / video ? ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_device " value = " <?= $monitor[Device] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Device Channel </ td >< td align = " left " class = " text " >< input type = " text " name = " new_channel " value = " <?= $monitor[Channel] ?> " size = " 4 " class = " form " ></ td ></ tr >
2003-01-16 22:55:17 +08:00
< tr >< td align = " left " class = " text " > Device Format ( 0 = PAL , 1 = NTSC etc ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_format " value = " <?= $monitor[Format] ?> " size = " 4 " class = " form " ></ td ></ tr >
2003-04-13 00:17:17 +08:00
< tr >< td align = " left " class = " text " > Capture Palette </ td >< td align = " left " class = " text " >< select name = " new_palette " class = " form " >< ? php foreach ( $local_palettes as $name => $value ) { ?> <option value="<?= $value ?>"<?php if ( $value == $monitor[Palette] ) { ?> selected<?php } ?>><?= $name ?></option><?php } ?></select></td></tr>
2003-03-26 19:41:22 +08:00
< ? php
}
else
{
?>
< tr >< td align = " left " class = " text " > Remote Host Name </ td >< td align = " left " class = " text " >< input type = " text " name = " new_host " value = " <?= $monitor[Host] ?> " size = " 16 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Remote Host Port </ td >< td align = " left " class = " text " >< input type = " text " name = " new_port " value = " <?= $monitor[Port] ?> " size = " 6 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Remote Host Path </ td >< td align = " left " class = " text " >< input type = " text " name = " new_path " value = " <?= $monitor[Path] ?> " size = " 36 " class = " form " ></ td ></ tr >
2003-04-13 00:17:17 +08:00
< tr >< td align = " left " class = " text " > Remote Image Colours </ td >< td align = " left " class = " text " >< select name = " new_palette " class = " form " >< ? php foreach ( $remote_palettes as $name => $value ) { ?> <option value= <?= $value ?>"<?php if ( $value == $monitor[Palette] ) { ?> selected<?php } ?>><?= $name ?></option><?php } ?></select></td></tr>
2003-03-26 19:41:22 +08:00
< ? php
}
?>
< tr >< td align = " left " class = " text " > Capture Width ( pixels ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_width " value = " <?= $monitor[Width] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Capture Height ( pixels ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_height " value = " <?= $monitor[Height] ?> " size = " 4 " class = " form " ></ td ></ tr >
2003-01-14 00:39:00 +08:00
< tr >< td align = " left " class = " text " > Timestamp Label Format </ td >< td align = " left " class = " text " >< input type = " text " name = " new_label_format " value = " <?= $monitor[LabelFormat] ?> " size = " 20 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Timestamp Label X </ td >< td align = " left " class = " text " >< input type = " text " name = " new_label_x " value = " <?= $monitor[LabelX] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Timestamp Label Y </ td >< td align = " left " class = " text " >< input type = " text " name = " new_label_y " value = " <?= $monitor[LabelY] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Image Buffer Size ( frames ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_image_buffer_count " value = " <?= $monitor[ImageBufferCount] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Warmup Frames </ td >< td align = " left " class = " text " >< input type = " text " name = " new_warmup_count " value = " <?= $monitor[WarmupCount] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Pre Event Image Buffer </ td >< td align = " left " class = " text " >< input type = " text " name = " new_pre_event_count " value = " <?= $monitor[PreEventCount] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Post Event Image Buffer </ td >< td align = " left " class = " text " >< input type = " text " name = " new_post_event_count " value = " <?= $monitor[PostEventCount] ?> " size = " 4 " class = " form " ></ td ></ tr >
2003-03-27 06:12:25 +08:00
< tr >< td align = " left " class = " text " > Maximum FPS </ td >< td align = " left " class = " text " >< input type = " text " name = " new_max_fps " value = " <?= $monitor[MaxFPS] ?> " size = " 4 " class = " form " ></ td ></ tr >
2003-01-14 00:39:00 +08:00
< tr >< td align = " left " class = " text " > FPS Report Interval </ td >< td align = " left " class = " text " >< input type = " text " name = " new_fps_report_interval " value = " <?= $monitor[FPSReportInterval] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Reference Image Blend % ge </ td >< td align = " left " class = " text " >< input type = " text " name = " new_ref_blend_perc " value = " <?= $monitor[RefBlendPerc] ?> " size = " 4 " class = " form " ></ td ></ tr >
2003-01-11 01:12:23 +08:00
< ? php if ( ZM_OPT_X10 ) { ?>
2003-01-14 00:39:00 +08:00
< tr >< td align = " left " class = " text " > X10 Activation String </ td >< td align = " left " class = " text " >< input type = " text " name = " new_x10_activation " value = " <?= $monitor[X10Activation] ?> " size = " 20 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > X10 Input Alarm String </ td >< td align = " left " class = " text " >< input type = " text " name = " new_x10_alarm_input " value = " <?= $monitor[X10AlarmInput] ?> " size = " 20 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > X10 Output Alarm String </ td >< td align = " left " class = " text " >< input type = " text " name = " new_x10_alarm_output " value = " <?= $monitor[X10AlarmOutput] ?> " size = " 20 " class = " form " ></ td ></ tr >
2003-01-03 00:56:23 +08:00
< ? php } ?>
2002-10-11 17:45:06 +08:00
< tr >< td colspan = " 2 " align = " left " class = " text " >& nbsp ; </ td ></ tr >
< tr >
2003-03-26 19:41:22 +08:00
< td align = " left " >< input type = " submit " value = " Save " class = " form " onClick = " monitorForm.view.value='none'; monitorForm.action.value='monitor'; " ></ td >
2002-10-11 17:45:06 +08:00
< td align = " left " >< input type = " button " value = " Cancel " class = " form " onClick = " closeWindow() " ></ td >
</ tr >
</ table >
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
}
case " zone " :
2002-10-11 17:45:06 +08:00
{
2002-10-28 04:25:27 +08:00
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
2002-10-11 17:45:06 +08:00
if ( ! $result )
die ( mysql_error () );
2002-10-28 04:25:27 +08:00
$monitor = mysql_fetch_assoc ( $result );
if ( $zid > 0 )
{
$result = mysql_query ( " select * from Zones where MonitorId = ' $mid ' and Id = ' $zid ' " );
if ( ! $result )
die ( mysql_error () );
$zone = mysql_fetch_assoc ( $result );
}
else
{
$zone = array ();
$zone [ Name ] = " New " ;
$zone [ LoX ] = 0 ;
$zone [ LoY ] = 0 ;
$zone [ HiX ] = $monitor [ Width ] - 1 ;
$zone [ HiY ] = $monitor [ Height ] - 1 ;
}
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - < ? = $monitor [ Name ] ?> - Zone <?= $zone[Name] ?></title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
< ? php
2002-10-28 04:25:27 +08:00
if ( $refresh_parent )
{
2002-10-11 17:45:06 +08:00
?>
opener . location . reload ();
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
window . focus ();
function validateForm ( theForm )
{
theForm . new_alarm_rgb . value = ( theForm . new_alarm_rgb_r . value << 16 ) | ( theForm . new_alarm_rgb_g . value << 8 ) | theForm . new_alarm_rgb_b . value ;
return ( true );
}
function applyZoneType ( theForm )
{
if ( theForm . new_type . value == 'Inactive' )
{
theForm . new_alarm_rgb_r . disabled = true ;
theForm . new_alarm_rgb_r . value = " " ;
theForm . new_alarm_rgb_g . disabled = true ;
theForm . new_alarm_rgb_g . value = " " ;
theForm . new_alarm_rgb_b . disabled = true ;
theForm . new_alarm_rgb_b . value = " " ;
theForm . new_alarm_threshold . disabled = true ;
theForm . new_alarm_threshold . value = " " ;
theForm . new_min_alarm_pixels . disabled = true ;
theForm . new_min_alarm_pixels . value = " " ;
theForm . new_max_alarm_pixels . disabled = true ;
theForm . new_max_alarm_pixels . value = " " ;
theForm . new_filter_x . disabled = true ;
theForm . new_filter_x . value = " " ;
theForm . new_filter_y . disabled = true ;
theForm . new_filter_y . value = " " ;
theForm . new_min_filter_pixels . disabled = true ;
theForm . new_min_filter_pixels . value = " " ;
theForm . new_max_filter_pixels . disabled = true ;
theForm . new_max_filter_pixels . value = " " ;
theForm . new_min_blob_pixels . disabled = true ;
theForm . new_min_blob_pixels . value = " " ;
theForm . new_max_blob_pixels . disabled = true ;
theForm . new_max_blob_pixels . value = " " ;
theForm . new_min_blobs . disabled = true ;
theForm . new_min_blobs . value = " " ;
theForm . new_max_blobs . disabled = true ;
theForm . new_max_blobs . value = " " ;
}
2003-04-13 20:20:00 +08:00
else if ( theForm . new_type . value == 'Preventive' )
{
theForm . new_alarm_rgb_r . disabled = true ;
theForm . new_alarm_rgb_r . value = " " ;
theForm . new_alarm_rgb_g . disabled = true ;
theForm . new_alarm_rgb_g . value = " " ;
theForm . new_alarm_rgb_b . disabled = true ;
theForm . new_alarm_rgb_b . value = " " ;
theForm . new_alarm_threshold . disabled = false ;
theForm . new_alarm_threshold . value = " <?= $zone[AlarmThreshold] ?> " ;
theForm . new_min_alarm_pixels . disabled = false ;
theForm . new_min_alarm_pixels . value = " <?= $zone[MinAlarmPixels] ?> " ;
theForm . new_max_alarm_pixels . disabled = false ;
theForm . new_max_alarm_pixels . value = " <?= $zone[MaxAlarmPixels] ?> " ;
theForm . new_filter_x . disabled = false ;
theForm . new_filter_x . value = " <?= $zone[FilterX] ?> " ;
theForm . new_filter_y . disabled = false ;
theForm . new_filter_y . value = " <?= $zone[FilterY] ?> " ;
theForm . new_min_filter_pixels . disabled = false ;
theForm . new_min_filter_pixels . value = " <?= $zone[MinFilterPixels] ?> " ;
theForm . new_max_filter_pixels . disabled = false ;
theForm . new_max_filter_pixels . value = " <?= $zone[MaxFilterPixels] ?> " ;
theForm . new_min_blob_pixels . disabled = false ;
theForm . new_min_blob_pixels . value = " <?= $zone[MinBlobPixels] ?> " ;
theForm . new_max_blob_pixels . disabled = false ;
theForm . new_max_blob_pixels . value = " <?= $zone[MaxBlobPixels] ?> " ;
theForm . new_min_blobs . disabled = false ;
theForm . new_min_blobs . value = " <?= $zone[MinBlobs] ?> " ;
theForm . new_max_blobs . disabled = false ;
theForm . new_max_blobs . value = " <?= $zone[MaxBlobs] ?> " ;
}
2002-10-11 17:45:06 +08:00
else
{
theForm . new_alarm_rgb_r . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_alarm_rgb_r . value = " <?= ( $zone[AlarmRGB] >>16)&0xff; ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_alarm_rgb_g . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_alarm_rgb_g . value = " <?= ( $zone[AlarmRGB] >>8)&0xff; ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_alarm_rgb_b . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_alarm_rgb_b . value = " <?= $zone[AlarmRGB] &0xff; ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_alarm_threshold . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_alarm_threshold . value = " <?= $zone[AlarmThreshold] ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_min_alarm_pixels . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_min_alarm_pixels . value = " <?= $zone[MinAlarmPixels] ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_max_alarm_pixels . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_max_alarm_pixels . value = " <?= $zone[MaxAlarmPixels] ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_filter_x . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_filter_x . value = " <?= $zone[FilterX] ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_filter_y . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_filter_y . value = " <?= $zone[FilterY] ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_min_filter_pixels . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_min_filter_pixels . value = " <?= $zone[MinFilterPixels] ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_max_filter_pixels . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_max_filter_pixels . value = " <?= $zone[MaxFilterPixels] ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_min_blob_pixels . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_min_blob_pixels . value = " <?= $zone[MinBlobPixels] ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_max_blob_pixels . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_max_blob_pixels . value = " <?= $zone[MaxBlobPixels] ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_min_blobs . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_min_blobs . value = " <?= $zone[MinBlobs] ?> " ;
2002-10-11 17:45:06 +08:00
theForm . new_max_blobs . disabled = false ;
2003-01-14 00:39:00 +08:00
theForm . new_max_blobs . value = " <?= $zone[MaxBlobs] ?> " ;
2002-10-11 17:45:06 +08:00
}
}
function toPixels ( theField , maxValue )
{
theField . value = Math . round (( theField . value * maxValue ) / 100 );
}
function toPercent ( theField , maxValue )
{
theField . value = Math . round (( 100 * theField . value ) / maxValue );
}
function applyZoneUnits ( theForm )
{
2003-01-14 00:39:00 +08:00
var max_width = < ? = $monitor [ Width ] - 1 ?> ;
var max_height = < ? = $monitor [ Height ] - 1 ?> ;
2002-10-11 17:45:06 +08:00
var area = ( max_width + 1 ) * ( max_height + 1 );
if ( theForm . new_units . value == 'Pixels' )
{
toPixels ( theForm . new_lo_x , max_width );
toPixels ( theForm . new_lo_y , max_height );
toPixels ( theForm . new_hi_x , max_width );
toPixels ( theForm . new_hi_y , max_height );
toPixels ( theForm . new_min_alarm_pixels , area );
toPixels ( theForm . new_max_alarm_pixels , area );
toPixels ( theForm . new_min_filter_pixels , area );
toPixels ( theForm . new_max_filter_pixels , area );
toPixels ( theForm . new_min_blob_pixels , area );
toPixels ( theForm . new_max_blob_pixels , area );
}
else
{
toPercent ( theForm . new_lo_x , max_width );
toPercent ( theForm . new_lo_y , max_height );
toPercent ( theForm . new_hi_x , max_width );
toPercent ( theForm . new_hi_y , max_height );
toPercent ( theForm . new_min_alarm_pixels , area );
toPercent ( theForm . new_max_alarm_pixels , area );
toPercent ( theForm . new_min_filter_pixels , area );
toPercent ( theForm . new_max_filter_pixels , area );
toPercent ( theForm . new_min_blob_pixels , area );
toPercent ( theForm . new_max_blob_pixels , area );
}
}
function checkBounds ( theField , fieldText , minValue , maxValue )
{
if ( document . zoneForm . new_units . value == " Percent " )
{
minValue = 0 ;
maxValue = 100 ;
}
if ( theField . value < minValue )
{
alert ( fieldText + " must be greater than or equal to " + minValue );
theField . value = minValue ;
}
if ( theField . value > maxValue )
{
alert ( fieldText + " must be less than or equal to " + maxValue );
theField . value = maxValue ;
}
}
function checkWidth ( theField , fieldText )
{
2003-01-14 00:39:00 +08:00
return ( checkBounds ( theField , fieldText , 0 , < ? = $monitor [ Width ] - 1 ?> ) );
2002-10-11 17:45:06 +08:00
}
function checkHeight ( theField , fieldText )
{
2003-01-14 00:39:00 +08:00
return ( checkBounds ( theField , fieldText , 0 , < ? = $monitor [ Height ] - 1 ?> ) );
2002-10-11 17:45:06 +08:00
}
function checkArea ( theField , fieldText )
{
2003-01-14 00:39:00 +08:00
return ( checkBounds ( theField , fieldText , 0 , < ? = $monitor [ Width ] * $monitor [ Height ] ?> ) );
2002-10-11 17:45:06 +08:00
}
2002-10-22 21:56:37 +08:00
function closeWindow ()
{
window . close ();
2002-10-11 17:45:06 +08:00
}
</ script >
</ head >
< body >
< table border = " 0 " cellspacing = " 0 " cellpadding = " 0 " width = " 100% " >
< tr >
2003-01-14 00:39:00 +08:00
< td colspan = " 2 " align = " left " class = " head " > Monitor < ? = $monitor [ Name ] ?> - Zone <?= $zone[Name] ?></td>
2002-10-11 17:45:06 +08:00
</ tr >
2003-01-14 00:39:00 +08:00
< form name = " zoneForm " method = " get " action = " <?= $PHP_SELF ?> " onsubmit = " return validateForm(this) " >
< input type = " hidden " name = " view " value = " <?= $view ?> " >
2002-10-11 17:45:06 +08:00
< input type = " hidden " name = " action " value = " zone " >
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " mid " value = " <?= $mid ?> " >
< input type = " hidden " name = " zid " value = " <?= $zid ?> " >
2002-10-11 17:45:06 +08:00
< input type = " hidden " name = " new_alarm_rgb " value = " " >
< tr >
< td align = " left " class = " smallhead " > Parameter </ td >< td align = " left " class = " smallhead " > Value </ td >
</ tr >
2003-01-14 00:39:00 +08:00
< tr >< td align = " left " class = " text " > Name </ td >< td align = " left " class = " text " >< input type = " text " name = " new_name " value = " <?= $zone[Name] ?> " size = " 12 " class = " form " ></ td ></ tr >
2002-10-11 17:45:06 +08:00
< tr >< td align = " left " class = " text " > Type </ td >< td align = " left " class = " text " >< select name = " new_type " class = " form " onchange = " applyZoneType(zoneForm) " >
< ? php
2002-10-28 04:25:27 +08:00
foreach ( getEnumValues ( 'Zones' , 'Type' ) as $opt_type )
{
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< option value = " <?= $opt_type ?> " < ? php if ( $opt_type == $zone [ 'Type' ] ) { ?> selected<?php } ?>><?= $opt_type ?></option>
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
</ select ></ td ></ tr >
< tr >< td align = " left " class = " text " > Units </ td >< td align = " left " class = " text " >< select name = " new_units " class = " form " onchange = " applyZoneUnits(zoneForm) " >
< ? php
2002-10-28 04:25:27 +08:00
foreach ( getEnumValues ( 'Zones' , 'Units' ) as $opt_units )
{
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< option value = " <?= $opt_units ?> " < ? php if ( $opt_units == $zone [ 'Units' ] ) { ?> selected<?php } ?>><?= $opt_units ?></option>
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
</ select ></ td ></ tr >
2003-01-14 00:39:00 +08:00
< tr >< td align = " left " class = " text " > Minimum X ( left ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_lo_x " value = " <?= $zone[LoX] ?> " size = " 4 " class = " form " onchange = " checkWidth(this,'Minimum X') " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Minimum Y ( top ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_lo_y " value = " <?= $zone[LoY] ?> " size = " 4 " class = " form " onchange = " checkHeight(this,'Minimum Y') " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Maximum X ( right ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_hi_x " value = " <?= $zone[HiX] ?> " size = " 4 " class = " form " onchange = " checkWidth(this,'Maximum X') " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Maximum Y ( bottom ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_hi_y " value = " <?= $zone[HiY] ?> " size = " 4 " class = " form " onchange = " checkHeight(this,'Maximum Y') " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Alarm Colour ( RGB ) </ td >< td align = " left " class = " text " > R :< input type = " text " name = " new_alarm_rgb_r " value = " <?= ( $zone[AlarmRGB] >>16)&0xff ?> " size = " 3 " class = " form " >& nbsp ; G :< input type = " text " name = " new_alarm_rgb_g " value = " <?= ( $zone[AlarmRGB] >>8)&0xff ?> " size = " 3 " class = " form " >& nbsp ; B :< input type = " text " name = " new_alarm_rgb_b " value = " <?= $zone[AlarmRGB] &0xff ?> " size = " 3 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Alarm Threshold ( 0 >= ? <= 255 ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_alarm_threshold " value = " <?= $zone[AlarmThreshold] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Minimum Alarmed Area </ td >< td align = " left " class = " text " >< input type = " text " name = " new_min_alarm_pixels " value = " <?= $zone[MinAlarmPixels] ?> " size = " 6 " class = " form " onchange = " checkArea(this,'Minimum Alarmed Area') " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Maximum Alarmed Area </ td >< td align = " left " class = " text " >< input type = " text " name = " new_max_alarm_pixels " value = " <?= $zone[MaxAlarmPixels] ?> " size = " 6 " class = " form " onchange = " checkArea(this,'Maximum Alarmed Area') " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Filter Width ( pixels ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_filter_x " value = " <?= $zone[FilterX] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Filter Height ( pixels ) </ td >< td align = " left " class = " text " >< input type = " text " name = " new_filter_y " value = " <?= $zone[FilterY] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Minimum Filtered Area </ td >< td align = " left " class = " text " >< input type = " text " name = " new_min_filter_pixels " value = " <?= $zone[MinFilterPixels] ?> " size = " 6 " class = " form " onchange = " checkArea(this,'Minimum Filtered Area') " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Maximum Filtered Area </ td >< td align = " left " class = " text " >< input type = " text " name = " new_max_filter_pixels " value = " <?= $zone[MaxFilterPixels] ?> " size = " 6 " class = " form " onchange = " checkArea(this,'Minimum Filtered Area') " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Minimum Blob Area </ td >< td align = " left " class = " text " >< input type = " text " name = " new_min_blob_pixels " value = " <?= $zone[MinBlobPixels] ?> " size = " 6 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Maximum Blob Area </ td >< td align = " left " class = " text " >< input type = " text " name = " new_max_blob_pixels " value = " <?= $zone[MaxBlobPixels] ?> " size = " 6 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Minimum Blobs </ td >< td align = " left " class = " text " >< input type = " text " name = " new_min_blobs " value = " <?= $zone[MinBlobs] ?> " size = " 4 " class = " form " ></ td ></ tr >
< tr >< td align = " left " class = " text " > Maximum Blobs </ td >< td align = " left " class = " text " >< input type = " text " name = " new_max_blobs " value = " <?= $zone[MaxBlobs] ?> " size = " 4 " class = " form " ></ td ></ tr >
2002-10-11 17:45:06 +08:00
< tr >< td colspan = " 2 " align = " left " class = " text " >& nbsp ; </ td ></ tr >
< tr >
2002-10-30 06:03:12 +08:00
< td align = " left " >< input type = " submit " value = " Save " class = " form " ></ td >
2002-10-11 17:45:06 +08:00
< td align = " left " >< input type = " button " value = " Cancel " class = " form " onClick = " closeWindow() " ></ td >
</ tr >
</ table >
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
}
case " video " :
{
2003-04-13 00:17:17 +08:00
$result = mysql_query ( " select E.*,M.Name as MonitorName, M.Palette from Events as E, Monitors as M where E.Id = ' $eid ' and E.MonitorId = M.Id " );
2002-10-28 04:25:27 +08:00
if ( ! $result )
die ( mysql_error () );
$event = mysql_fetch_assoc ( $result );
2002-10-11 17:45:06 +08:00
2003-03-21 17:40:46 +08:00
$event_dir = ZM_DIR_EVENTS . " / $event[MonitorName] / " . sprintf ( " %d " , $eid );
2002-10-28 04:25:27 +08:00
$param_file = $event_dir . " /mpeg.param " ;
$video_name = preg_replace ( " / \\ s/ " , " _ " , $event [ Name ] ) . " .mpeg " ;
$video_file = $event_dir . " / " . $video_name ;
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
if ( ! file_exists ( $video_file ) )
{
$fp = fopen ( $param_file , " w " );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
fputs ( $fp , " PATTERN IBBPBBPBBPBBPBB \n " );
fputs ( $fp , " OUTPUT $video_file\n " );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
fputs ( $fp , " BASE_FILE_FORMAT JPEG \n " );
fputs ( $fp , " GOP_SIZE 30 \n " );
fputs ( $fp , " SLICES_PER_FRAME 1 \n " );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
fputs ( $fp , " PIXEL HALF \n " );
fputs ( $fp , " RANGE 10 \n " );
fputs ( $fp , " PSEARCH_ALG LOGARITHMIC \n " );
fputs ( $fp , " BSEARCH_ALG CROSS2 \n " );
fputs ( $fp , " IQSCALE 8 \n " );
fputs ( $fp , " PQSCALE 10 \n " );
fputs ( $fp , " BQSCALE 25 \n " );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
fputs ( $fp , " REFERENCE_FRAME ORIGINAL \n " );
fputs ( $fp , " FRAME_RATE 24 \n " );
2002-10-11 17:45:06 +08:00
2003-04-13 00:17:17 +08:00
if ( $event [ Palette ] == 1 )
2003-01-11 01:12:23 +08:00
fputs ( $fp , " INPUT_CONVERT " . ZM_PATH_NETPBM . " /jpegtopnm * | " . ZM_PATH_NETPBM . " /pgmtoppm white | " . ZM_PATH_NETPBM . " /ppmtojpeg \n " );
2002-10-28 04:25:27 +08:00
else
fputs ( $fp , " INPUT_CONVERT * \n " );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
fputs ( $fp , " INPUT_DIR $event_dir\n " );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
fputs ( $fp , " INPUT \n " );
for ( $i = 1 ; $i < $event [ Frames ]; $i ++ )
{
fputs ( $fp , " capture- " . sprintf ( " %03d " , $i ) . " .jpg \n " );
fputs ( $fp , " capture- " . sprintf ( " %03d " , $i ) . " .jpg \n " );
}
fputs ( $fp , " END_INPUT \n " );
fclose ( $fp );
2003-01-11 01:12:23 +08:00
exec ( ZM_PATH_MPEG_ENCODE . " $param_file > $event_dir /mpeg.log " );
2002-10-11 17:45:06 +08:00
}
2002-10-28 04:25:27 +08:00
//chdir( $event_dir );
//header("Content-type: video/mpeg");
//header("Content-Disposition: inline; filename=$video_name");
header ( " Location: $video_file " );
2002-10-11 17:45:06 +08:00
2002-10-28 04:25:27 +08:00
break ;
2002-10-11 17:45:06 +08:00
}
2002-10-28 04:25:27 +08:00
case " function " :
{
$result = mysql_query ( " select * from Monitors where Id = ' $mid ' " );
if ( ! $result )
die ( mysql_error () );
$monitor = mysql_fetch_assoc ( $result );
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
2003-01-14 00:39:00 +08:00
< title > ZM - Function - < ? = $monitor [ Name ] ?> </title>
2003-04-10 20:14:15 +08:00
< link rel = " stylesheet " href = " zm_styles.css " type = " text/css " >
2002-10-11 17:45:06 +08:00
< script language = " JavaScript " >
< ? php
2002-10-28 04:25:27 +08:00
if ( $refresh_parent )
{
2002-10-11 17:45:06 +08:00
?>
opener . location . reload ();
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
window . focus ();
2002-10-22 21:56:37 +08:00
function refreshWindow ()
{
window . location . reload ();
2002-10-11 17:45:06 +08:00
}
2002-10-22 21:56:37 +08:00
function closeWindow ()
{
window . close ();
2002-10-11 17:45:06 +08:00
}
</ script >
</ head >
< body >
< table border = " 0 " cellspacing = " 0 " cellpadding = " 4 " width = " 100% " >
< tr >
2003-01-14 00:39:00 +08:00
< td colspan = " 2 " align = " center " class = " head " > Monitor '<?= $monitor[Name] ?>' Function </ td >
2002-10-11 17:45:06 +08:00
</ tr >
< tr >
2003-01-14 00:39:00 +08:00
< form method = " get " action = " <?= $PHP_SELF ?> " >
2002-12-24 19:56:34 +08:00
< input type = " hidden " name = " view " value = " none " >
2002-10-11 17:45:06 +08:00
< input type = " hidden " name = " action " value = " function " >
2003-01-14 00:39:00 +08:00
< input type = " hidden " name = " mid " value = " <?= $mid ?> " >
2002-10-11 17:45:06 +08:00
< td colspan = " 2 " align = " center " >< select name = " new_function " class = " form " >
< ? php
2002-10-28 04:25:27 +08:00
foreach ( getEnumValues ( 'Monitors' , 'Function' ) as $opt_function )
{
2003-01-11 01:12:23 +08:00
if ( ! ZM_OPT_X10 && $opt_function == 'X10' )
2003-01-02 19:59:52 +08:00
continue ;
2002-10-11 17:45:06 +08:00
?>
2003-01-14 00:39:00 +08:00
< option value = " <?= $opt_function ?> " < ? php if ( $opt_function == $monitor [ 'Function' ] ) { ?> selected<?php } ?>><?= $opt_function ?></option>
2002-10-11 17:45:06 +08:00
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
</ select ></ td >
</ tr >
< tr >
2002-10-30 06:03:12 +08:00
< td align = " center " >< input type = " submit " value = " Save " class = " form " ></ td >
2002-10-11 17:45:06 +08:00
< td align = " center " >< input type = " button " value = " Cancel " class = " form " onClick = " closeWindow() " ></ td >
</ tr >
</ table >
</ body >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
}
case " none " :
{
2002-10-11 17:45:06 +08:00
?>
< html >
< head >
< script language = " JavaScript " >
< ? php
2002-10-28 04:25:27 +08:00
if ( $refresh_parent )
{
2002-10-11 17:45:06 +08:00
?>
2003-01-16 22:55:17 +08:00
//self.onerror = function() { return( true ); }
2002-10-11 17:45:06 +08:00
opener . location . reload ();
< ? php
2002-10-28 04:25:27 +08:00
}
2002-10-11 17:45:06 +08:00
?>
window . close ();
</ script >
</ head >
</ html >
< ? php
2002-10-28 04:25:27 +08:00
break ;
}
2002-10-11 17:45:06 +08:00
}
?>
2002-10-22 21:56:37 +08:00
< ? php
function buildSelect ( $name , $contents , $onchange = " " )
{
global $$name ;
?>
2003-01-14 00:39:00 +08:00
< select name = " <?= $name ?> " class = " form " < ? php if ( $onchange ) { echo " onChange= \" $onchange\ " " ; } ?>>
2002-10-22 21:56:37 +08:00
< ? php
foreach ( $contents as $content_value => $content_text )
{
?>
2003-01-14 00:39:00 +08:00
< option value = " <?= $content_value ?> " < ? php if ( $$name == $content_value ) { echo " selected " ; } ?> ><?= $content_text ?></option>
2002-10-22 21:56:37 +08:00
< ? php
}
?>
</ select >
< ? php
}
?>