123 lines
4.2 KiB
PHP
123 lines
4.2 KiB
PHP
|
<?php
|
||
|
//
|
||
|
// ZoneMinder web watch view file, $Date$, $Revision$
|
||
|
// Copyright (C) 2003 Philip Coombes
|
||
|
//
|
||
|
// 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 ( !canView( 'Stream' ) )
|
||
|
{
|
||
|
$view = "error";
|
||
|
return;
|
||
|
}
|
||
|
$result = mysql_query( "select * from Monitors where Id = '$mid'" );
|
||
|
if ( !$result )
|
||
|
die( mysql_error() );
|
||
|
$monitor = mysql_fetch_assoc( $result );
|
||
|
|
||
|
if ( !isset($scale) )
|
||
|
$scale = ZM_WEB_DEFAULT_SCALE;
|
||
|
|
||
|
$width_scale = ($scale<SCALE_SCALE)?SCALE_SCALE:$scale;
|
||
|
$height_scale = $scale;
|
||
|
|
||
|
$zmu_command = ZMU_COMMAND." -m $mid -s -f";
|
||
|
$zmu_output = exec( escapeshellcmd( $zmu_command ) );
|
||
|
list( $status, $fps ) = split( ' ', $zmu_output );
|
||
|
$status_string = $zmSlangUnknown;
|
||
|
$fps_string = "--.--";
|
||
|
$class = "text";
|
||
|
if ( $status == 0 )
|
||
|
{
|
||
|
$status_string = $zmSlangIdle;
|
||
|
}
|
||
|
elseif ( $status == 1 )
|
||
|
{
|
||
|
$status_string = $zmSlangAlarm;
|
||
|
$class = "redtext";
|
||
|
}
|
||
|
elseif ( $status == 2 )
|
||
|
{
|
||
|
$status_string = $zmSlangAlert;
|
||
|
$class = "ambtext";
|
||
|
}
|
||
|
elseif ( $status == 3 )
|
||
|
{
|
||
|
$status_string = $zmSlangRecord;
|
||
|
}
|
||
|
$fps_string = sprintf( "%.2f", $fps );
|
||
|
$new_alarm = ( $status > 0 && $last_status == 0 );
|
||
|
$old_alarm = ( $status == 0 && $last_status > 0 );
|
||
|
|
||
|
$result = mysql_query( "select * from Monitors where Function != 'None' order by Id" );
|
||
|
$monitors = array();
|
||
|
$mon_idx = 0;
|
||
|
$max_width = 0;
|
||
|
$max_height = 0;
|
||
|
while( $row = mysql_fetch_assoc( $result ) )
|
||
|
{
|
||
|
if ( !visibleMonitor( $row['Id'] ) )
|
||
|
{
|
||
|
continue;
|
||
|
}
|
||
|
if ( isset($mid) && $row['Id'] == $mid )
|
||
|
$mon_idx = count($monitors);
|
||
|
if ( $max_width < $row['Width'] ) $max_width = $row['Width'];
|
||
|
if ( $max_height < $row['Height'] ) $max_height = $row['Height'];
|
||
|
$monitors[] = $row;
|
||
|
}
|
||
|
//$monitor = $monitors[$mon_idx];
|
||
|
$next_mid = $mon_idx==(count($monitors)-1)?$monitors[0]['Id']:$monitors[$mon_idx+1]['Id'];
|
||
|
$prev_mid = $mon_idx==0?$mon_index[(count($monitors)-1)]['Id']:$monitors[$mon_idx-1]['Id'];
|
||
|
|
||
|
$device_width = (isset($device)&&!empty($device['width']))?$device['width']:DEVICE_WIDTH;
|
||
|
$device_height = (isset($device)&&!empty($device['height']))?$device['height']:DEVICE_HEIGHT;
|
||
|
// Allow for margins etc
|
||
|
$device_width -= 16;
|
||
|
$device_height -= 16;
|
||
|
|
||
|
$width_scale = ($device_width*SCALE_SCALE)/$monitor['Width'];
|
||
|
$height_scale = ($device_height*SCALE_SCALE)/$monitor['Height'];
|
||
|
$scale = (int)(($width_scale<$height_scale)?$width_scale:$height_scale);
|
||
|
|
||
|
$image_src = ZM_PATH_ZMS."?mode=single&monitor=".$monitor['Id']."&scale=".$scale;
|
||
|
|
||
|
?>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>ZM - <?= $monitor['Name'] ?> - <?= $zmSlangWatch ?></title>
|
||
|
<link rel="stylesheet" href="zm_xhtml_styles.css" type="text/css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<p class="<?= $class ?>" align="center"><?= makeLink( "$PHP_SELF?view=events&page=1&filter=1&trms=1&attr1=MonitorId&op1=%3d&val1=".$monitor['Id']."&&sort_field=Id&sort_desc=1", $monitor['Name'], canView( 'Events' ) ) ?>: <?= $status_string ?> - <?= $fps_string ?> fps</p>
|
||
|
<p align="center"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mid=<?= $monitor['Id'] ?>"><img src="<?= $image_src ?>" style="border: 0" width="<?= reScale( $monitor['Width'], $scale ) ?>" height="<?= reScale( $monitor['Height'], $scale ) ?>" alt="<?= $monitor['Name'] ?>"></a></p>
|
||
|
<?php
|
||
|
if ( $next_mod != $mid || $prev_mid != $mid )
|
||
|
{
|
||
|
?>
|
||
|
<table>
|
||
|
<tr>
|
||
|
<td align="left"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mid=<?= $prev_mid ?>"><?= $zmSlangPrev ?></a></td>
|
||
|
<td align="center"><a href="<?= $PHP_SELF ?>?view=console"><?= $zmSlangConsole ?></a></td>
|
||
|
<td align="right"><a href="<?= $PHP_SELF ?>?view=<?= $view ?>&mid=<?= $next_mid ?>"><?= $zmSlangNext ?></a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
<?php
|
||
|
}
|
||
|
?>
|
||
|
</body>
|
||
|
</html>
|