2009-03-31 21:00:49 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// ZoneMinder web monitor probe view file, $Date: 2008-09-26 10:47:20 +0100 (Fri, 26 Sep 2008) $, $Revision: 2632 $
|
|
|
|
// Copyright (C) 2001-2008 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 ( !canEdit( 'Monitors' ) )
|
|
|
|
{
|
|
|
|
$view = "error";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$cameras = array();
|
|
|
|
$cameras[0] = $SLANG['ChooseDetectedCamera'];
|
|
|
|
|
2011-05-22 17:25:33 +08:00
|
|
|
if ( ZM_HAS_V4L2 )
|
2009-03-31 21:00:49 +08:00
|
|
|
{
|
|
|
|
// Probe Local Cameras
|
|
|
|
//
|
|
|
|
$command = getZmuCommand( " --query --device" );
|
|
|
|
if ( !empty($_REQUEST['device']) )
|
|
|
|
$command .= "=".escapeshellarg($_REQUEST['device']);
|
|
|
|
|
|
|
|
$result = exec( escapeshellcmd($command), $output, $status );
|
|
|
|
if ( $status )
|
2011-06-21 17:19:10 +08:00
|
|
|
Fatal( "Unable to probe local cameras, status is '$status'" );
|
2009-03-31 21:00:49 +08:00
|
|
|
|
|
|
|
$monitors = array();
|
|
|
|
foreach ( dbFetchAll( "select Id, Name, Device,Channel from Monitors where Type = 'Local' order by Device, Channel" ) as $monitor )
|
|
|
|
$monitors[$monitor['Device'].':'.$monitor['Channel']] = $monitor;
|
|
|
|
|
|
|
|
$devices = array();
|
|
|
|
$preferredStandards = array( 'PAL', 'NTSC' );
|
2011-07-01 23:01:24 +08:00
|
|
|
$preferredFormats = array( 'BGR4', 'RGB4', 'BGR3', 'RGB3', 'YUYV', 'JPEG', 'MJPG', '422P', 'GREY');
|
2009-03-31 21:00:49 +08:00
|
|
|
foreach ( $output as $line )
|
|
|
|
{
|
2010-03-01 01:38:30 +08:00
|
|
|
if ( !preg_match( '/^d:([^|]+).*S:([^|]*).*F:([^|]+).*I:(\d+)\|(.+)$/', $line, $deviceMatches ) )
|
2011-06-21 17:19:10 +08:00
|
|
|
Fatal( "Can't parse command output '$line'" );
|
2010-02-23 17:10:36 +08:00
|
|
|
$standards = explode('/',$deviceMatches[2]);
|
2009-03-31 21:00:49 +08:00
|
|
|
$preferredStandard = false;
|
|
|
|
foreach ( $preferredStandards as $standard )
|
|
|
|
{
|
|
|
|
if ( in_array( $standard, $standards ) )
|
|
|
|
{
|
|
|
|
$preferredStandard = $standard;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-02-23 17:10:36 +08:00
|
|
|
$formats = explode('/',$deviceMatches[3]);
|
2009-03-31 21:00:49 +08:00
|
|
|
$preferredFormat = false;
|
|
|
|
foreach ( $preferredFormats as $format )
|
|
|
|
{
|
|
|
|
if ( in_array( $format, $formats ) )
|
|
|
|
{
|
|
|
|
$preferredFormat = $format;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$device = array( 'device'=>$deviceMatches[1], 'standards'=>$standard, 'preferredStandard'=>$preferredStandard, 'formats'=>$formats, 'preferredFormat'=>$preferredFormat );
|
|
|
|
$inputs = array();
|
|
|
|
for ( $i = 0; $i < $deviceMatches[4]; $i++ )
|
|
|
|
{
|
|
|
|
if ( !preg_match( '/i'.$i.':([^|]+)\|i'.$i.'T:([^|]+)\|/', $deviceMatches[5], $inputMatches ) )
|
2011-06-21 17:19:10 +08:00
|
|
|
Fatal( "Can't parse input '".$deviceMatches[5]."'" );
|
2009-03-31 21:00:49 +08:00
|
|
|
if ( $inputMatches[2] == 'Camera' )
|
|
|
|
{
|
|
|
|
$input = array( 'index'=>$i, 'id'=>$deviceMatches[1].':'.$i, 'name'=>$inputMatches[1], 'free'=>empty($monitors[$deviceMatches[1].':'.$i]) );
|
|
|
|
$inputMonitor = array(
|
|
|
|
'Type' => 'Local',
|
|
|
|
'Device' => $deviceMatches[1],
|
|
|
|
'Channel' => $i,
|
2011-05-22 17:25:33 +08:00
|
|
|
'Colours' => 4,
|
2009-03-31 21:00:49 +08:00
|
|
|
'Format' => $preferredStandard,
|
|
|
|
'Palette' => $preferredFormat,
|
|
|
|
);
|
|
|
|
if ( $preferredStandard == 'NTSC' )
|
|
|
|
{
|
|
|
|
$inputMonitor['Width'] = 320;
|
|
|
|
$inputMonitor['Height'] = 240;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-22 17:25:33 +08:00
|
|
|
$inputMonitor['Width'] = 384;
|
2009-03-31 21:00:49 +08:00
|
|
|
$inputMonitor['Height'] = 288;
|
|
|
|
}
|
2011-05-22 17:25:33 +08:00
|
|
|
if ( $preferredFormat == 'GREY' )
|
|
|
|
{
|
|
|
|
$inputMonitor['Colours'] = 1;
|
|
|
|
$inputMonitor['SignalCheckColour'] = '#000023';
|
|
|
|
}
|
|
|
|
$inputDesc = base64_encode(serialize($inputMonitor));
|
2009-03-31 21:00:49 +08:00
|
|
|
$inputString = $deviceMatches[1].', chan '.$i.($input['free']?(" - ".$SLANG['Available']):(" (".$monitors[$input['id']]['Name'].")"));
|
|
|
|
$inputs[] = $input;
|
|
|
|
$cameras[$inputDesc] = $inputString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$device['inputs'] = $inputs;
|
|
|
|
$devices[] = $device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Probe Network Cameras
|
|
|
|
//
|
|
|
|
function probeAxis( $ip )
|
|
|
|
{
|
|
|
|
$url = 'http://'.$ip.'/axis-cgi/admin/param.cgi?action=list&group=Brand';
|
|
|
|
$camera = array(
|
|
|
|
'model' => "Unknown Axis Camera",
|
|
|
|
'monitor' => array(
|
|
|
|
'Type' => 'Remote',
|
|
|
|
'Protocol' => 'http',
|
|
|
|
'Host' => $ip,
|
|
|
|
'Port' => 80,
|
|
|
|
'Path' => '/axis-cgi/mjpg/video.cgi?resolution=320x240',
|
2011-05-22 17:25:33 +08:00
|
|
|
'Colours' => 4,
|
2009-03-31 21:00:49 +08:00
|
|
|
'Width' => 320,
|
|
|
|
'Height' => 240,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
if ( $lines = @file( $url ) )
|
|
|
|
{
|
|
|
|
foreach ( $lines as $line )
|
|
|
|
{
|
|
|
|
$line = rtrim( $line );
|
|
|
|
if ( preg_match( '/^(.+)=(.+)$/', $line, $matches ) )
|
|
|
|
{
|
|
|
|
if ( $matches[1] == 'root.Brand.ProdShortName' )
|
|
|
|
{
|
|
|
|
$camera['model'] = $matches[2];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( $camera );
|
|
|
|
}
|
|
|
|
|
|
|
|
function probePana( $ip )
|
|
|
|
{
|
|
|
|
$url = 'http://'.$ip.'/Get?Func=Model&Kind=1';
|
|
|
|
$camera = array(
|
|
|
|
'model' => "Unknown Panasonic Camera",
|
|
|
|
'monitor' => array(
|
|
|
|
'Type' => 'Remote',
|
|
|
|
'Protocol' => 'http',
|
|
|
|
'Host' => $ip,
|
|
|
|
'Port' => 80,
|
|
|
|
'Path' => '/nphMotionJpeg?Resolution=320x240&Quality=Standard',
|
2011-05-22 17:25:33 +08:00
|
|
|
'Colours' => 4,
|
2009-03-31 21:00:49 +08:00
|
|
|
'Width' => 320,
|
|
|
|
'Height' => 240,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return( $camera );
|
|
|
|
}
|
|
|
|
|
|
|
|
function probeActi( $ip )
|
|
|
|
{
|
|
|
|
$url = 'http://'.$ip.'/cgi-bin/system?USER=Admin&PWD=123456&SYSTEM_INFO';
|
|
|
|
$camera = array(
|
|
|
|
'model' => "Unknown Panasonic Camera",
|
|
|
|
'monitor' => array(
|
|
|
|
'Type' => 'Remote',
|
|
|
|
'Protocol' => 'rtsp',
|
|
|
|
'Method' => 'rtpUni',
|
|
|
|
'Host' => 'Admin:123456@'.$ip,
|
|
|
|
'Port' => 7070,
|
|
|
|
'Path' => '',
|
2011-05-22 17:25:33 +08:00
|
|
|
'Colours' => 4,
|
2009-03-31 21:00:49 +08:00
|
|
|
'Width' => 320,
|
|
|
|
'Height' => 240,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
if ( $lines = @file( $url ) )
|
|
|
|
{
|
|
|
|
foreach ( $lines as $line )
|
|
|
|
{
|
|
|
|
$line = rtrim( $line );
|
|
|
|
if ( preg_match( '/^(.+?)\s*=\s*(.+)$/', $line, $matches ) )
|
|
|
|
{
|
|
|
|
if ( $matches[1] == 'Production ID' )
|
|
|
|
{
|
|
|
|
$camera['model'] = "ACTi ".substr( $matches[2], 0, strpos( $matches[2], '-' ));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( $camera );
|
|
|
|
}
|
|
|
|
|
2009-05-28 16:47:59 +08:00
|
|
|
function probeVivotek( $ip )
|
|
|
|
{
|
|
|
|
$url = 'http://'.$ip.'/cgi-bin/viewer/getparam.cgi';
|
|
|
|
$camera = array(
|
|
|
|
'model' => "Unknown Vivotek Camera",
|
|
|
|
'monitor' => array(
|
|
|
|
'Type' => 'Remote',
|
|
|
|
'Protocol' => 'rtsp',
|
|
|
|
'Method' => 'rtpUni',
|
|
|
|
'Host' => $ip,
|
|
|
|
'Port' => 554,
|
|
|
|
'Path' => '',
|
2011-05-22 17:25:33 +08:00
|
|
|
'Colours' => 4,
|
2009-05-28 16:47:59 +08:00
|
|
|
'Width' => 352,
|
|
|
|
'Height' => 240,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
if ( $lines = @file( $url ) )
|
|
|
|
{
|
|
|
|
foreach ( $lines as $line )
|
|
|
|
{
|
|
|
|
$line = rtrim( $line );
|
|
|
|
if ( preg_match( '/^(.+?)\s*=\'(.+)\'$/', $line, $matches ) )
|
|
|
|
{
|
|
|
|
if ( $matches[1] == 'system_info_modelname' )
|
|
|
|
{
|
|
|
|
$camera['model'] = "Vivotek ".$matches[2];
|
|
|
|
}
|
|
|
|
elseif ( $matches[1] == 'network_rtsp_port' )
|
|
|
|
{
|
|
|
|
$camera['monitor']['Port'] = $matches[2];
|
|
|
|
}
|
|
|
|
elseif ( $matches[1] == 'network_rtsp_s0_accessname' )
|
|
|
|
{
|
|
|
|
$camera['monitor']['Path'] = $matches[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( $camera );
|
|
|
|
}
|
|
|
|
|
2009-03-31 21:00:49 +08:00
|
|
|
$monitors = array();
|
2009-05-28 16:47:59 +08:00
|
|
|
foreach ( dbFetchAll( "select Id, Name, Host from Monitors where Type = 'Remote' order by Host" ) as $monitor )
|
|
|
|
{
|
2009-03-31 21:00:49 +08:00
|
|
|
if ( preg_match( '/^(.+)@(.+)$/', $monitor['Host'], $matches ) )
|
2009-05-28 16:47:59 +08:00
|
|
|
{
|
|
|
|
//echo "1: ".$matches[2]." = ".gethostbyname($matches[2])."<br/>";
|
2009-03-31 21:00:49 +08:00
|
|
|
$monitors[gethostbyname($matches[2])] = $monitor;
|
2009-05-28 16:47:59 +08:00
|
|
|
}
|
2009-03-31 21:00:49 +08:00
|
|
|
else
|
2009-05-28 16:47:59 +08:00
|
|
|
{
|
|
|
|
//echo "2: ".$monitor['Host']." = ".gethostbyname($monitor['Host'])."<br/>";
|
2009-03-31 21:00:49 +08:00
|
|
|
$monitors[gethostbyname($monitor['Host'])] = $monitor;
|
2009-05-28 16:47:59 +08:00
|
|
|
}
|
|
|
|
}
|
2009-03-31 21:00:49 +08:00
|
|
|
$macBases = array(
|
|
|
|
'00:40:8c' => array( 'type'=>'Axis', 'probeFunc'=>'probeAxis' ),
|
|
|
|
'00:80:f0' => array( 'type'=>'Panasonic','probeFunc'=>'probePana' ),
|
|
|
|
'00:0f:7c' => array( 'type'=>'ACTi','probeFunc'=>'probeACTi' ),
|
2009-05-28 16:47:59 +08:00
|
|
|
'00:02:d1' => array( 'type'=>'Vivotek','probeFunc'=>'probeVivotek' ),
|
2009-03-31 21:00:49 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
unset($output);
|
|
|
|
$command = "arp -a";
|
|
|
|
$result = exec( escapeshellcmd($command), $output, $status );
|
|
|
|
if ( $status )
|
2011-06-21 17:19:10 +08:00
|
|
|
Fatal( "Unable to probe network cameras, status is '$status'" );
|
2009-03-31 21:00:49 +08:00
|
|
|
foreach ( $output as $line )
|
|
|
|
{
|
|
|
|
if ( !preg_match( '/^(\S+) \(([\d.]+)\) at ([0-9a-f:]+)/', $line, $matches ) )
|
2010-11-03 23:46:57 +08:00
|
|
|
continue;
|
2009-03-31 21:00:49 +08:00
|
|
|
$host = $matches[1];
|
|
|
|
$ip = $matches[2];
|
|
|
|
if ( !$host || $host == '?' )
|
|
|
|
$host = $ip;
|
|
|
|
$mac = $matches[3];
|
|
|
|
//echo "I:$ip, H:$host, M:$mac<br/>";
|
|
|
|
$macRoot = substr($mac,0,8);
|
|
|
|
if ( isset($macBases[$macRoot]) )
|
|
|
|
{
|
|
|
|
$macBase = $macBases[$macRoot];
|
|
|
|
$camera = call_user_func( $macBase['probeFunc'], $ip );
|
|
|
|
$sourceDesc = htmlspecialchars(serialize($camera['monitor']));
|
|
|
|
$sourceString = $camera['model'].' @ '.$host;
|
|
|
|
if ( isset($monitors[$ip]) )
|
|
|
|
{
|
|
|
|
$monitor = $monitors[$ip];
|
|
|
|
$sourceString .= " (".$monitor['Name'].")";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$sourceString .= " - ".$SLANG['Available'];
|
|
|
|
}
|
|
|
|
$cameras[$sourceDesc] = $sourceString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( count($cameras) <= 0 )
|
|
|
|
$cameras[0] = $SLANG['NoDetectedCameras'];
|
|
|
|
|
|
|
|
$focusWindow = true;
|
|
|
|
|
|
|
|
xhtmlHeaders(__FILE__, $SLANG['MonitorProbe'] );
|
|
|
|
?>
|
|
|
|
<body>
|
|
|
|
<div id="page">
|
|
|
|
<div id="header">
|
|
|
|
<h2><?= $SLANG['MonitorProbe'] ?></h2>
|
|
|
|
</div>
|
|
|
|
<div id="content">
|
|
|
|
<form name="contentForm" id="contentForm" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
|
|
|
|
<input type="hidden" name="view" value="none"/>
|
|
|
|
<input type="hidden" name="mid" value="<?= validNum($_REQUEST['mid']) ?>"/>
|
|
|
|
<p>
|
|
|
|
<?= $SLANG['MonitorProbeIntro'] ?>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<label for="probe"><?= $SLANG['DetectedCameras'] ?></label><?= buildSelect( "probe", $cameras, 'configureButtons( this )' ); ?>
|
|
|
|
</p>
|
|
|
|
<div id="contentButtons">
|
|
|
|
<input type="submit" name="saveBtn" value="<?= $SLANG['Save'] ?>" onclick="submitCamera( this )" disabled="disabled"/><input type="button" value="<?= $SLANG['Cancel'] ?>" onclick="closeWindow()"/>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|