2020-10-29 00:49:39 +08:00
|
|
|
var ZM_OPT_USE_GEOLOCATION = '<?php echo ZM_OPT_USE_GEOLOCATION ?>' == '1' ? true : false;
|
2020-09-25 08:30:57 +08:00
|
|
|
<?php
|
|
|
|
if ( ZM_OPT_USE_GEOLOCATION ) {
|
|
|
|
echo 'var ZM_OPT_GEOLOCATION_TILE_PROVIDER=\''.ZM_OPT_GEOLOCATION_TILE_PROVIDER.'\''.PHP_EOL;
|
|
|
|
echo 'var ZM_OPT_GEOLOCATION_ACCESS_TOKEN=\''.ZM_OPT_GEOLOCATION_ACCESS_TOKEN.'\''.PHP_EOL;
|
|
|
|
}
|
|
|
|
?>
|
2014-12-05 07:44:23 +08:00
|
|
|
var optControl = <?php echo ZM_OPT_CONTROL ?>;
|
2020-08-29 04:22:57 +08:00
|
|
|
var hasOnvif = <?php echo ZM_HAS_ONVIF ?>;
|
2014-12-05 07:44:23 +08:00
|
|
|
var defaultAspectRatio = '<?php echo ZM_DEFAULT_ASPECT_RATIO ?>';
|
2013-05-02 22:20:06 +08:00
|
|
|
|
|
|
|
<?php
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( ZM_OPT_CONTROL ) {
|
2013-05-02 22:20:06 +08:00
|
|
|
?>
|
|
|
|
var controlOptions = new Object();
|
|
|
|
<?php
|
2020-09-08 01:29:21 +08:00
|
|
|
global $controls;
|
2020-09-05 20:46:18 +08:00
|
|
|
foreach ( $controls as $control ) {
|
2019-09-25 22:14:41 +08:00
|
|
|
echo '
|
2020-09-05 20:46:18 +08:00
|
|
|
controlOptions['.$control->Id().'] = new Array();
|
|
|
|
controlOptions['.$control->Id().'][0] = '.
|
|
|
|
( $control->HasHomePreset() ? '\''.translate('Home').'\'' : 'null' ).PHP_EOL;
|
|
|
|
for ( $i = 1; $i <= $control->NumPresets(); $i++ ) {
|
|
|
|
echo 'controlOptions['. $control->Id().']['.$i.'] = \''.translate('Preset').' '.$i .'\';'.PHP_EOL;
|
2013-05-02 22:20:06 +08:00
|
|
|
}
|
2019-09-25 22:14:41 +08:00
|
|
|
} # end foreach row
|
|
|
|
} # end if ZM_OPT_CONTROL
|
2013-05-02 22:20:06 +08:00
|
|
|
?>
|
|
|
|
|
|
|
|
var monitorNames = new Object();
|
2021-04-17 23:51:12 +08:00
|
|
|
var rtspStreamNames = new Object();
|
2013-05-02 22:20:06 +08:00
|
|
|
<?php
|
2021-04-17 23:51:12 +08:00
|
|
|
$query = empty($_REQUEST['mid']) ?
|
|
|
|
dbQuery('SELECT Name,RTSPStreamName FROM Monitors') :
|
|
|
|
dbQuery('SELECT Name,RTSPStreamName FROM Monitors WHERE Id != ?', array($_REQUEST['mid']) );
|
|
|
|
if ($query) {
|
|
|
|
while ($row = dbFetchNext($query)) {
|
2019-09-25 22:14:41 +08:00
|
|
|
echo '
|
2021-04-17 23:51:12 +08:00
|
|
|
monitorNames[\''.validJsStr($row['Name']).'\'] = true;
|
|
|
|
rtspStreamNames[\''.validJsStr($row['RTSPStreamName']).'\'] = true;
|
2019-09-25 22:14:41 +08:00
|
|
|
';
|
|
|
|
} // end foreach
|
2018-01-24 05:28:29 +08:00
|
|
|
} # end if query
|
2013-05-02 22:20:06 +08:00
|
|
|
?>
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function validateForm( form ) {
|
|
|
|
var errors = new Array();
|
2021-05-18 22:53:16 +08:00
|
|
|
var warnings = new Array();
|
2013-05-02 22:20:06 +08:00
|
|
|
|
2017-10-11 03:15:41 +08:00
|
|
|
if ( form.elements['newMonitor[Name]'].value.search( /[^\w\-\.\(\)\:\/ ]/ ) >= 0 )
|
2017-05-19 01:50:56 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadNameChars') ?>";
|
2018-01-23 00:42:52 +08:00
|
|
|
else if ( monitorNames[form.elements['newMonitor[Name]'].value] )
|
2017-05-19 01:50:56 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('DuplicateMonitorName') ?>";
|
2015-07-23 03:38:35 +08:00
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( form.elements['newMonitor[Type]'].value == 'Local' ) {
|
|
|
|
if ( !form.elements['newMonitor[Palette]'].value || !form.elements['newMonitor[Palette]'].value.match( /^\d+$/ ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadPalette') ?>";
|
|
|
|
if ( !form.elements['newMonitor[Device]'].value )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadDevice') ?>";
|
|
|
|
if ( !form.elements['newMonitor[Channel]'].value || !form.elements['newMonitor[Channel]'].value.match( /^\d+$/ ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadChannel') ?>";
|
|
|
|
if ( !form.elements['newMonitor[Format]'].value || !form.elements['newMonitor[Format]'].value.match( /^\d+$/ ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadFormat') ?>";
|
2021-01-29 22:53:11 +08:00
|
|
|
if ( form.elements['newMonitor[VideoWriter]'].value == 2 /* Passthrough */ )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadPassthrough') ?>";
|
2017-05-19 01:50:56 +08:00
|
|
|
} else if ( form.elements['newMonitor[Type]'].value == 'Remote' ) {
|
2017-05-19 02:24:09 +08:00
|
|
|
//if ( !form.elements['newMonitor[Host]'].value || !form.elements['newMonitor[Host]'].value.match( /^[0-9a-zA-Z_.:@-]+$/ ) )
|
|
|
|
//errors[errors.length] = "<?php echo translate('BadHost') ?>";
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( form.elements['newMonitor[Port]'].value && !form.elements['newMonitor[Port]'].value.match( /^\d+$/ ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadPort') ?>";
|
|
|
|
//if ( !form.elements['newMonitor[Path]'].value )
|
|
|
|
//errors[errors.length] = "<?php echo translate('BadPath') ?>";
|
2021-01-29 22:53:11 +08:00
|
|
|
if ( form.elements['newMonitor[VideoWriter]'].value == 2 /* Passthrough */ )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadPassthrough') ?>";
|
2019-09-20 02:56:16 +08:00
|
|
|
} else if ( form.elements['newMonitor[Type]'].value == 'Ffmpeg' ) {
|
2021-05-04 22:45:27 +08:00
|
|
|
if ( !form.elements['newMonitor[Path]'].value ) {
|
2019-09-20 02:56:16 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadPath') ?>";
|
2021-05-27 06:50:26 +08:00
|
|
|
} else if (form.elements['newMonitor[Path]'].value.match(/[\!\*'\(\)\$ ,#]/)) {
|
2021-05-06 22:55:16 +08:00
|
|
|
warnings[warnings.length] = "<?php echo translate('BadPathNotEncoded') ?>";
|
2021-05-04 22:45:27 +08:00
|
|
|
}
|
2019-09-20 02:56:16 +08:00
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
} else if ( form.elements['newMonitor[Type]'].value == 'File' ) {
|
|
|
|
if ( !form.elements['newMonitor[Path]'].value )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadPath') ?>";
|
2021-01-29 22:53:11 +08:00
|
|
|
if ( form.elements['newMonitor[VideoWriter]'].value == 2 /* Passthrough */ )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadPassthrough') ?>";
|
2018-04-27 05:18:36 +08:00
|
|
|
} else if ( form.elements['newMonitor[Type]'].value == 'WebSite' ) {
|
|
|
|
if ( form.elements['newMonitor[Function]'].value != 'Monitor' && form.elements['newMonitor[Function]'].value != 'None')
|
|
|
|
errors[errors.length] = "<?php echo translate('BadSourceType') ?>";
|
|
|
|
if ( form.elements['newMonitor[Path]'].value.search(/^https?:\/\//i) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadWebSitePath') ?>";
|
|
|
|
}
|
|
|
|
|
2021-04-01 22:14:18 +08:00
|
|
|
if (form.elements['newMonitor[VideoWriter]'].value == '1' /* Encode */) {
|
|
|
|
var parameters = form.elements['newMonitor[EncoderParameters]'].value.replace(/[^#a-zA-Z]/g, "");
|
|
|
|
if (parameters == '' || parameters == '#Linesbeginningwith#areacomment#Forchangingqualityusethecrfoption#isbestisworstquality#crf' ) {
|
2021-05-06 22:55:16 +08:00
|
|
|
warnings[warnings.length] = '<?php echo translate('BadEncoderParameters') ?>';
|
2021-04-01 22:14:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-27 05:18:36 +08:00
|
|
|
if ( form.elements['newMonitor[Type]'].value != 'WebSite' ) {
|
|
|
|
|
|
|
|
if ( form.elements['newMonitor[AnalysisFPSLimit]'].value && !(parseFloat(form.elements['newMonitor[AnalysisFPSLimit]'].value) > 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadAnalysisFPS') ?>";
|
|
|
|
if ( form.elements['newMonitor[MaxFPS]'].value && !(parseFloat(form.elements['newMonitor[MaxFPS]'].value) > 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadMaxFPS') ?>";
|
|
|
|
if ( form.elements['newMonitor[AlarmMaxFPS]'].value && !(parseFloat(form.elements['newMonitor[AlarmMaxFPS]'].value) > 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadAlarmMaxFPS') ?>";
|
|
|
|
if ( !form.elements['newMonitor[RefBlendPerc]'].value || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) > 100 ) || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) < 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadRefBlendPerc') ?>";
|
|
|
|
|
|
|
|
if ( !form.elements['newMonitor[Colours]'].value || (parseInt(form.elements['newMonitor[Colours]'].value) != 1 && parseInt(form.elements['newMonitor[Colours]'].value) != 3 && parseInt(form.elements['newMonitor[Colours]'].value) != 4 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadColours') ?>";
|
|
|
|
if ( !form.elements['newMonitor[Width]'].value || !(parseInt(form.elements['newMonitor[Width]'].value) > 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadWidth') ?>";
|
|
|
|
if ( !form.elements['newMonitor[Height]'].value || !(parseInt(form.elements['newMonitor[Height]'].value) > 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadHeight') ?>";
|
|
|
|
if ( !form.elements['newMonitor[LabelX]'].value || !(parseInt(form.elements['newMonitor[LabelX]'].value) >= 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadLabelX') ?>";
|
|
|
|
if ( !form.elements['newMonitor[LabelY]'].value || !(parseInt(form.elements['newMonitor[LabelY]'].value) >= 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadLabelY') ?>";
|
2021-01-27 04:33:38 +08:00
|
|
|
if ( !form.elements['newMonitor[ImageBufferCount]'].value || !(parseInt(form.elements['newMonitor[ImageBufferCount]'].value) >= 2 ) )
|
2018-04-27 05:18:36 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadImageBufferCount') ?>";
|
|
|
|
if ( !form.elements['newMonitor[WarmupCount]'].value || !(parseInt(form.elements['newMonitor[WarmupCount]'].value) >= 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadWarmupCount') ?>";
|
2021-01-27 04:33:38 +08:00
|
|
|
if (
|
|
|
|
!form.elements['newMonitor[PreEventCount]'].value
|
|
|
|
||
|
|
|
|
!(parseInt(form.elements['newMonitor[PreEventCount]'].value) >= 0)
|
|
|
|
)
|
2018-04-27 05:18:36 +08:00
|
|
|
errors[errors.length] = "<?php echo translate('BadPreEventCount') ?>";
|
|
|
|
if ( !form.elements['newMonitor[PostEventCount]'].value || !(parseInt(form.elements['newMonitor[PostEventCount]'].value) >= 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadPostEventCount') ?>";
|
|
|
|
if ( !form.elements['newMonitor[StreamReplayBuffer]'].value || !(parseInt(form.elements['newMonitor[StreamReplayBuffer]'].value) >= 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadStreamReplayBuffer') ?>";
|
|
|
|
if ( !form.elements['newMonitor[AlarmFrameCount]'].value || !(parseInt(form.elements['newMonitor[AlarmFrameCount]'].value) > 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadAlarmFrameCount') ?>";
|
|
|
|
if ( !form.elements['newMonitor[SectionLength]'].value || !(parseInt(form.elements['newMonitor[SectionLength]'].value) >= 30 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadSectionLength') ?>";
|
|
|
|
if ( !form.elements['newMonitor[AnalysisUpdateDelay]'].value || !(parseInt(form.elements['newMonitor[AnalysisUpdateDelay]'].value) >= 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadAnalysisUpdateDelay') ?>";
|
|
|
|
if ( !form.elements['newMonitor[FPSReportInterval]'].value || !(parseInt(form.elements['newMonitor[FPSReportInterval]'].value) >= 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadFPSReportInterval') ?>";
|
|
|
|
if ( !form.elements['newMonitor[FrameSkip]'].value || !(parseInt(form.elements['newMonitor[FrameSkip]'].value) >= 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadFrameSkip') ?>";
|
|
|
|
if ( !form.elements['newMonitor[MotionFrameSkip]'].value || !(parseInt(form.elements['newMonitor[MotionFrameSkip]'].value) >= 0 ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadMotionFrameSkip') ?>";
|
|
|
|
if ( form.elements['newMonitor[Type]'].value == 'Local' )
|
|
|
|
if ( !form.elements['newMonitor[SignalCheckColour]'].value || !form.elements['newMonitor[SignalCheckColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadSignalCheckColour') ?>";
|
|
|
|
if ( !form.elements['newMonitor[WebColour]'].value || !form.elements['newMonitor[WebColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
|
|
|
|
errors[errors.length] = "<?php echo translate('BadWebColour') ?>";
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2013-05-02 22:20:06 +08:00
|
|
|
|
2021-04-17 23:51:12 +08:00
|
|
|
if ( form.elements['newMonitor[RTSPStreamName]'].value
|
|
|
|
&&
|
|
|
|
rtspStreamNames[form.elements['newMonitor[RTSPStreamName]'].value]
|
|
|
|
)
|
|
|
|
errors[errors.length] = "<?php echo translate('DuplicateRTSPStreamName') ?>";
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
if ( errors.length ) {
|
2019-09-20 02:56:16 +08:00
|
|
|
alert(errors.join("\n"));
|
2019-02-08 22:55:32 +08:00
|
|
|
return false;
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2019-09-25 22:14:41 +08:00
|
|
|
|
|
|
|
if ( (form.elements['newMonitor[Function]'].value != 'Monitor') && (form.elements['newMonitor[Function]'].value != 'None') ) {
|
|
|
|
if ( (form.elements['newMonitor[SaveJPEGs]'].value == '0') && (form.elements['newMonitor[VideoWriter]'].value == '0') ) {
|
|
|
|
warnings[warnings.length] = "<?php echo translate('BadNoSaveJPEGsOrVideoWriter'); ?>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( warnings.length ) {
|
|
|
|
if ( !confirm(warnings.join("\n")) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-08 22:55:32 +08:00
|
|
|
return true;
|
2013-05-02 22:20:06 +08:00
|
|
|
}
|
|
|
|
|
2019-09-20 02:56:16 +08:00
|
|
|
function updateMethods(element) {
|
2017-05-19 01:50:56 +08:00
|
|
|
var form = element.form;
|
2013-05-02 22:20:06 +08:00
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
var origMethod = form.elements['origMethod'];
|
|
|
|
var methodSelector = form.elements['newMonitor[Method]'];
|
|
|
|
methodSelector.options.length = 0;
|
|
|
|
switch ( element.value ) {
|
|
|
|
case 'http' :
|
2019-09-20 02:56:16 +08:00
|
|
|
<?php
|
2020-08-05 04:36:24 +08:00
|
|
|
global $httpMethods;
|
2019-09-20 02:56:16 +08:00
|
|
|
foreach( $httpMethods as $value=>$label ) {
|
|
|
|
?>
|
|
|
|
methodSelector.options[methodSelector.options.length] = new Option("<?php echo htmlspecialchars($label) ?>", "<?php echo $value ?>");
|
|
|
|
if ( origMethod.value == "<?php echo $value ?>" )
|
|
|
|
methodSelector.selectedIndex = methodSelector.options.length-1;
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
2017-05-19 01:50:56 +08:00
|
|
|
break;
|
|
|
|
case 'rtsp' :
|
2019-09-20 02:56:16 +08:00
|
|
|
<?php
|
2020-08-05 04:36:24 +08:00
|
|
|
global $rtspMethods;
|
2019-09-20 02:56:16 +08:00
|
|
|
foreach( $rtspMethods as $value=>$label ) {
|
|
|
|
?>
|
|
|
|
methodSelector.options[methodSelector.options.length] = new Option( "<?php echo htmlspecialchars($label) ?>", "<?php echo $value ?>" );
|
|
|
|
if ( origMethod.value == "<?php echo $value ?>" )
|
|
|
|
methodSelector.selectedIndex = form.elements['newMonitor[Method]'].options.length-1;
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
break;
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2019-09-20 02:56:16 +08:00
|
|
|
return true;
|
2013-05-02 22:20:06 +08:00
|
|
|
}
|