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
|
|
|
|
|
|
|
$plugin_path = dirname(ZM_PLUGINS_CONFIG_PATH)."/".$plugin;
|
|
|
|
|
|
|
|
$focusWindow = true;
|
|
|
|
|
|
|
|
xhtmlHeaders(__FILE__, $SLANG['Plugin'] );
|
|
|
|
|
|
|
|
|
|
|
|
$pluginOptions=array(
|
|
|
|
'Enabled'=>array(
|
|
|
|
'Type'=>'select',
|
|
|
|
'Name'=>'Enabled',
|
|
|
|
'Choices'=>'yes,no',
|
|
|
|
'Value'=>'no'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$optionNames=array();
|
|
|
|
if(file_exists($plugin_path."/config.php"))
|
|
|
|
{
|
|
|
|
include_once($plugin_path."/config.php");
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
if(array_key_exists($popt['Name'], $pluginOptions)
|
|
|
|
&& $popt['Type']==$pluginOptions[$popt['Name']]['Type']
|
|
|
|
&& $popt['Choices']==$pluginOptions[$popt['Name']]['Choices']
|
|
|
|
)
|
|
|
|
{
|
|
|
|
$pluginOptions[$popt['Name']]=$popt;
|
|
|
|
array_push($optionNames, $popt['Name']);
|
|
|
|
} 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
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach($pluginOptions as $name => $values)
|
|
|
|
{
|
|
|
|
if(!in_array($name, $optionNames))
|
|
|
|
{
|
|
|
|
$popt=$pluginOptions[$name];
|
2013-12-18 01:53:15 +08:00
|
|
|
$sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,?,?,?,?)";
|
|
|
|
dbQuery($sql, array( $popt['Name'], $popt['Value'], $popt['Type'], $popt['Choices'], $mid, $zid, $plugin ) );
|
2013-03-17 07:45:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$PLANG=array();
|
|
|
|
if(file_exists($plugin_path."/lang/".$user['Language'].".php")) {
|
|
|
|
include_once($plugin_path."/lang/".$user['Language'].".php");
|
|
|
|
}
|
|
|
|
|
|
|
|
function pLang($name)
|
|
|
|
{
|
|
|
|
global $PLANG;
|
|
|
|
if(array_key_exists($name, $PLANG))
|
|
|
|
return $PLANG[$name];
|
|
|
|
else
|
|
|
|
return $name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
<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>
|
|
|
|
<?
|
|
|
|
foreach($pluginOptions as $name => $popt)
|
|
|
|
{
|
|
|
|
?>
|
2014-12-05 07:44:23 +08:00
|
|
|
<tr><th scope="row"><?php echo pLang($name) ?></th>
|
2013-03-17 07:45:21 +08:00
|
|
|
<?
|
|
|
|
switch($popt['Type'])
|
|
|
|
{
|
|
|
|
case "checkbox":
|
|
|
|
echo "CHECKBOX";
|
|
|
|
break;
|
|
|
|
case "select":
|
|
|
|
$pchoices=explode(',',$popt['Choices']);
|
|
|
|
?>
|
|
|
|
<td colspan="2">
|
2014-12-05 07:44:23 +08:00
|
|
|
<select name="pluginOpt[<?php echo $popt['Name'] ?>]" id="pluginOpt[<?php echo $popt['Name'] ?>]">
|
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>
|
2013-03-17 07:45:21 +08:00
|
|
|
<?
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</td>
|
|
|
|
</select>
|
|
|
|
<?
|
|
|
|
break;
|
|
|
|
case "text":
|
|
|
|
default:
|
|
|
|
echo "DEFAULT";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</tr>
|
|
|
|
<?
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</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>
|