2013-03-17 07:45:21 +08:00
|
|
|
<?php
|
|
|
|
//
|
|
|
|
// ZoneMinder web zone view file, $Date$, $Revision$
|
|
|
|
// 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 ( !canView( 'Monitors' ) )
|
|
|
|
{
|
|
|
|
$view = "error";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$mid = validInt($_REQUEST['mid']);
|
|
|
|
$zid = !empty($_REQUEST['zid'])?validInt($_REQUEST['zid']):0;
|
|
|
|
|
|
|
|
|
2013-12-18 01:53:15 +08:00
|
|
|
if ( $zid > 0 ) {
|
|
|
|
$newZone = dbFetchOne( 'SELECT * FROM Zones WHERE MonitorId = ? AND Id = ?', NULL, array( $mid, $zid) );
|
2013-03-17 07:45:21 +08:00
|
|
|
} else {
|
|
|
|
$view = "error";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$monitor = dbFetchMonitor ( $mid );
|
2013-12-18 01:53:15 +08:00
|
|
|
$plugin = $_REQUEST['pl'];
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2014-11-12 07:53:53 +08:00
|
|
|
$plugin_path = dirname($_SERVER['SCRIPT_FILENAME'])."/plugins/".$plugin;
|
2013-03-17 07:45:21 +08:00
|
|
|
|
|
|
|
$focusWindow = true;
|
|
|
|
|
2014-11-12 07:53:53 +08:00
|
|
|
$generalOptions=array(
|
|
|
|
'Enabled'=>array(
|
|
|
|
'Type'=>'select',
|
|
|
|
'Name'=>'Enabled',
|
|
|
|
'Choices'=>'Yes,No',
|
|
|
|
'Value'=>'No'
|
|
|
|
),
|
|
|
|
'RequireNatDet'=>array(
|
|
|
|
'Type'=>'select',
|
|
|
|
'Name'=>'RequireNatDet',
|
|
|
|
'Choices'=>'Yes,No',
|
|
|
|
'Value'=>'No',
|
|
|
|
'Require'=>array(
|
|
|
|
array(
|
|
|
|
'Name'=>'Enabled',
|
|
|
|
'Value'=>'Yes'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'IncludeNatDet'=>array(
|
|
|
|
'Type'=>'select',
|
|
|
|
'Name'=>'IncludeNatDet',
|
|
|
|
'Choices'=>'Yes,No',
|
|
|
|
'Value'=>'No',
|
|
|
|
'Require'=>array(
|
|
|
|
array(
|
|
|
|
'Name'=>'Enabled',
|
|
|
|
'Value'=>'Yes'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'Name'=>'RequireNatDet',
|
|
|
|
'Value'=>'Yes'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
'ReInitNatDet'=>array(
|
|
|
|
'Type'=>'select',
|
|
|
|
'Name'=>'ReInitNatDet',
|
|
|
|
'Choices'=>'Yes,No',
|
|
|
|
'Value'=>'No',
|
|
|
|
'Require'=>array(
|
|
|
|
array(
|
|
|
|
'Name'=>'Enabled',
|
|
|
|
'Value'=>'Yes'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'Name'=>'RequireNatDet',
|
|
|
|
'Value'=>'Yes'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
2015-01-04 21:01:01 +08:00
|
|
|
'AlarmScore'=>array(
|
2014-11-12 07:53:53 +08:00
|
|
|
'Type'=>'integer',
|
2015-01-04 21:01:01 +08:00
|
|
|
'Name'=>'AlarmScore',
|
2014-11-12 07:53:53 +08:00
|
|
|
'Min'=>'1',
|
|
|
|
'Max'=>'100',
|
|
|
|
'Value'=>'99',
|
|
|
|
'Require'=>array(
|
|
|
|
array(
|
|
|
|
'Name'=>'Enabled',
|
|
|
|
'Value'=>'Yes'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2014-11-12 07:53:53 +08:00
|
|
|
$options=$generalOptions;
|
2013-03-17 07:45:21 +08:00
|
|
|
$optionNames=array();
|
|
|
|
if(file_exists($plugin_path."/config.php"))
|
|
|
|
{
|
|
|
|
include_once($plugin_path."/config.php");
|
2014-11-12 07:53:53 +08:00
|
|
|
if(isset($pluginOptions))
|
|
|
|
foreach( $pluginOptions as $optionKey => $optionValue )
|
|
|
|
{
|
|
|
|
// Set default dependency information if not set in configuration file
|
|
|
|
if(!isset($optionValue['Require']))
|
|
|
|
$optionValue['Require'] = array (
|
|
|
|
array(
|
|
|
|
'Name'=>'Enabled',
|
|
|
|
'Value'=>'Yes'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$options[$optionKey]=$optionValue;
|
|
|
|
}
|
|
|
|
}
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2013-12-18 01:53:15 +08:00
|
|
|
$sql='SELECT * FROM PluginsConfig WHERE MonitorId=? AND ZoneId=? AND pluginName=?';
|
|
|
|
foreach( dbFetchAll( $sql, NULL, array( $mid, $zid, $plugin ) ) as $popt )
|
2013-03-17 07:45:21 +08:00
|
|
|
{
|
2014-11-12 07:53:53 +08:00
|
|
|
if(array_key_exists($popt['Name'], $options)
|
|
|
|
&& $popt['Type']==$options[$popt['Name']]['Type'])
|
2013-03-17 07:45:21 +08:00
|
|
|
{
|
|
|
|
array_push($optionNames, $popt['Name']);
|
2014-11-12 07:53:53 +08:00
|
|
|
|
|
|
|
// Backup dependency information
|
|
|
|
$require = '';
|
|
|
|
if(isset($options[$popt['Name']]['Require']))
|
|
|
|
$require = $options[$popt['Name']]['Require'];
|
|
|
|
|
|
|
|
// Set value from database
|
|
|
|
$options[$popt['Name']]=$popt;
|
|
|
|
|
|
|
|
// Restore dependancy information from backup
|
|
|
|
if(!empty($require))
|
|
|
|
$options[$popt['Name']]['Require'] = $require;
|
|
|
|
|
|
|
|
// Set default dependancy information if not set in configuration
|
|
|
|
else if($popt['Name'] != 'Enabled')
|
|
|
|
$options[$popt['Name']]['Require'] = array (
|
|
|
|
array(
|
|
|
|
'Name'=>'Enabled',
|
|
|
|
'Value'=>'Yes'
|
|
|
|
)
|
|
|
|
);
|
2013-03-17 07:45:21 +08:00
|
|
|
} else {
|
2013-12-18 01:53:15 +08:00
|
|
|
dbQuery('DELETE FROM PluginsConfig WHERE Id=?', array( $popt['Id'] ) );
|
2013-03-17 07:45:21 +08:00
|
|
|
}
|
|
|
|
}
|
2014-11-12 07:53:53 +08:00
|
|
|
|
|
|
|
foreach($options as $name => $values)
|
2013-03-17 07:45:21 +08:00
|
|
|
{
|
|
|
|
if(!in_array($name, $optionNames))
|
|
|
|
{
|
2014-11-12 07:53:53 +08:00
|
|
|
$popt=$options[$name];
|
|
|
|
switch($popt['Type'])
|
|
|
|
{
|
|
|
|
case "select":
|
|
|
|
$sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,?,'','',?,?,?)";
|
|
|
|
dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $popt['Choices'], $mid, $zid, $plugin ) );
|
|
|
|
break;
|
|
|
|
case "integer":
|
|
|
|
$sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,'',?,?,?,?,?)";
|
|
|
|
dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $popt['Min'], $popt['Max'], $mid, $zid, $plugin ) );
|
|
|
|
break;
|
|
|
|
case "checkbox":
|
|
|
|
case "text":
|
|
|
|
default:
|
|
|
|
$sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,'','','',?,?,?)";
|
|
|
|
dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $mid, $zid, $plugin ) );
|
|
|
|
}
|
2013-03-17 07:45:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$PLANG=array();
|
2014-11-12 07:53:53 +08:00
|
|
|
$lang_path = $plugin_path."/lang";
|
|
|
|
$userLangFile = $lang_path."/".$user['Language'].".php";
|
|
|
|
if (isset($user['Language']) && file_exists($userLangFile)) {
|
|
|
|
include_once($userLangFile);
|
|
|
|
} else {
|
|
|
|
$systemLangFile = $lang_path."/".ZM_LANG_DEFAULT.".php";
|
|
|
|
if (file_exists($systemLangFile)) {
|
|
|
|
include_once($systemLangFile);
|
|
|
|
} else {
|
|
|
|
$fallbackLangFile = $lang_path."/en_gb.php";
|
|
|
|
if (file_exists($fallbackLangFile)) {
|
|
|
|
include_once($fallbackLangFile);
|
|
|
|
}
|
|
|
|
}
|
2013-03-17 07:45:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function pLang($name)
|
|
|
|
{
|
2014-11-12 07:53:53 +08:00
|
|
|
global $SLANG;
|
2013-03-17 07:45:21 +08:00
|
|
|
global $PLANG;
|
2014-11-12 07:53:53 +08:00
|
|
|
if(array_key_exists($name, $SLANG))
|
|
|
|
return $SLANG[$name];
|
|
|
|
else if(array_key_exists($name, $PLANG))
|
2013-03-17 07:45:21 +08:00
|
|
|
return $PLANG[$name];
|
|
|
|
else
|
|
|
|
return $name;
|
|
|
|
}
|
|
|
|
|
2014-11-12 07:53:53 +08:00
|
|
|
function isEnabled($param)
|
|
|
|
{
|
|
|
|
global $options;
|
|
|
|
$option = $options[$param];
|
|
|
|
if (!isset($option['Require']))
|
|
|
|
return true;
|
|
|
|
foreach($option['Require'] as $req_couple)
|
|
|
|
{
|
|
|
|
$name = $req_couple['Name'];
|
|
|
|
if (!array_key_exists($name, $options))
|
|
|
|
continue;
|
|
|
|
if ($req_couple['Value'] != $options[$name]['Value'])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2014-11-12 07:53:53 +08:00
|
|
|
xhtmlHeaders(__FILE__, $SLANG['Plugin'] );
|
2013-03-17 07:45:21 +08:00
|
|
|
?>
|
|
|
|
<body>
|
|
|
|
<div id="page">
|
|
|
|
<div id="header">
|
2014-12-05 07:44:23 +08:00
|
|
|
<h2><?php echo $SLANG['Monitor'] ?> <?php echo $monitor['Name'] ?> - <?php echo $SLANG['Zone'] ?> <?php echo $newZone['Name'] ?> - <?php echo $SLANG['Plugin'] ?> <?php echo $plugin ?></h2>
|
2013-03-17 07:45:21 +08:00
|
|
|
</div>
|
|
|
|
<div id="content">
|
2014-12-05 07:44:23 +08:00
|
|
|
<form name="pluginForm" id="pluginForm" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
|
|
|
|
<input type="hidden" name="view" value="<?php echo $view ?>"/>
|
2013-03-17 07:45:21 +08:00
|
|
|
<input type="hidden" name="action" value="plugin"/>
|
2014-12-05 07:44:23 +08:00
|
|
|
<input type="hidden" name="mid" value="<?php echo $mid ?>"/>
|
|
|
|
<input type="hidden" name="zid" value="<?php echo $zid ?>"/>
|
|
|
|
<input type="hidden" name="pl" value="<?php echo $plugin ?>"/>
|
2013-03-17 07:45:21 +08:00
|
|
|
|
|
|
|
<div id="settingsPanel">
|
|
|
|
<table id="pluginSettings" cellspacing="0">
|
|
|
|
<tbody>
|
2014-12-22 07:28:16 +08:00
|
|
|
<?php
|
2014-11-12 07:53:53 +08:00
|
|
|
foreach($options as $name => $popt)
|
2013-03-17 07:45:21 +08:00
|
|
|
{
|
|
|
|
?>
|
2014-12-05 07:44:23 +08:00
|
|
|
<tr><th scope="row"><?php echo pLang($name) ?></th>
|
2014-12-22 07:28:16 +08:00
|
|
|
<?php
|
2013-03-17 07:45:21 +08:00
|
|
|
switch($popt['Type'])
|
|
|
|
{
|
|
|
|
case "checkbox":
|
2014-11-12 07:53:53 +08:00
|
|
|
?>
|
2014-12-22 07:28:16 +08:00
|
|
|
<td><input type="checkbox" name="pluginOpt[<?php echo $popt['Name'] ?>]" id="pluginOpt[<?php echo $popt['Name'] ?>]" <?php if ($popt['Value']) echo 'checked="checked"'; if (!isEnabled($popt['Name'])) echo 'disabled="disabled"'; ?>></td>
|
|
|
|
<?php
|
2013-03-17 07:45:21 +08:00
|
|
|
break;
|
|
|
|
case "select":
|
|
|
|
$pchoices=explode(',',$popt['Choices']);
|
|
|
|
?>
|
|
|
|
<td colspan="2">
|
2014-12-22 07:28:16 +08:00
|
|
|
<select name="pluginOpt[<?php echo $popt['Name'] ?>]" id="pluginOpt[<?php echo $popt['Name'] ?>]" <?php if (!isEnabled($popt['Name'])) echo 'disabled="disabled"'; ?> onchange="applyDependencies()" >
|
|
|
|
<?php
|
2013-03-17 07:45:21 +08:00
|
|
|
foreach($pchoices as $pchoice)
|
|
|
|
{
|
|
|
|
$psel="";
|
|
|
|
if($popt['Value']==$pchoice)
|
|
|
|
$psel="selected";
|
|
|
|
?>
|
2014-12-05 07:44:23 +08:00
|
|
|
<option value="<?php echo $pchoice ?>" <?php echo $psel ?>><?php echo pLang($pchoice) ?></option>
|
2014-12-22 07:28:16 +08:00
|
|
|
<?php
|
2013-03-17 07:45:21 +08:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</select>
|
2014-11-12 07:53:53 +08:00
|
|
|
</td>
|
2014-12-22 07:28:16 +08:00
|
|
|
<?php
|
2013-03-17 07:45:21 +08:00
|
|
|
break;
|
|
|
|
case "text":
|
2014-11-12 07:53:53 +08:00
|
|
|
?>
|
2014-12-22 07:28:16 +08:00
|
|
|
<td><input type="text" name="pluginOpt[<?php echo $popt['Name'] ?>]" id="pluginOpt[<?php echo $popt['Name'] ?>]" value="<?php echo $popt['Value'] ?>" <?php if (!isEnabled($popt['Name'])) echo 'disabled="disabled"'; ?>></td>
|
|
|
|
<?php
|
2014-11-12 07:53:53 +08:00
|
|
|
break;
|
|
|
|
case "integer":
|
|
|
|
?>
|
2014-12-22 07:28:16 +08:00
|
|
|
<td><input type="text" name="pluginOpt[<?php echo $popt['Name'] ?>]" id="pluginOpt[<?php echo $popt['Name'] ?>]" onchange="limitRange( this, <?php echo $popt['Min'] ?>, <?php echo $popt['Max'] ?> )" value="<?php echo $popt['Value'] ?>" size="4" <?php if (!isEnabled($popt['Name'])) echo 'disabled="disabled"'; ?>></td>
|
|
|
|
<?php
|
2014-11-12 07:53:53 +08:00
|
|
|
break;
|
2013-03-17 07:45:21 +08:00
|
|
|
default:
|
2014-11-12 07:53:53 +08:00
|
|
|
echo "Type '".$popt['Type']."' is not implemented<br>";
|
2013-03-17 07:45:21 +08:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</tr>
|
2014-12-22 07:28:16 +08:00
|
|
|
<?php
|
2013-03-17 07:45:21 +08:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2014-12-05 07:44:23 +08:00
|
|
|
<input type="submit" id="submitBtn" name="submitBtn" value="<?php echo $SLANG['Save'] ?>" onclick="return saveChanges( this )"<?php if (!canEdit( 'Monitors' ) || (false && $selfIntersecting)) { ?> disabled="disabled"<?php } ?>/><input type="button" value="<?php echo $SLANG['Cancel'] ?>" onclick="closeWindow()"/>
|
2013-03-17 07:45:21 +08:00
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|