0 ) { $newZone = dbFetchOne( 'SELECT * FROM Zones WHERE MonitorId = ? AND Id = ?', NULL, array( $mid, $zid) ); } else { $view = "error"; return; } $monitor = dbFetchMonitor ( $mid ); $plugin = $_REQUEST['pl']; $plugin_path = dirname($_SERVER['SCRIPT_FILENAME'])."/plugins/".$plugin; $focusWindow = true; $generalOptions=array( 'Enabled'=>array( 'Type'=>'select', 'Choices'=>'Yes,No', 'Value'=>'No' ), 'RequireNatDet'=>array( 'Type'=>'select', 'Choices'=>'Yes,No', 'Value'=>'No', 'Require'=>array( array( 'Name'=>'Enabled', 'Value'=>'Yes' ) ) ), 'IncludeNatDet'=>array( 'Type'=>'select', 'Choices'=>'Yes,No', 'Value'=>'No', 'Require'=>array( array( 'Name'=>'Enabled', 'Value'=>'Yes' ), array( 'Name'=>'RequireNatDet', 'Value'=>'Yes' ) ) ), 'ReInitNatDet'=>array( 'Type'=>'select', 'Choices'=>'Yes,No', 'Value'=>'No', 'Require'=>array( array( 'Name'=>'Enabled', 'Value'=>'Yes' ), array( 'Name'=>'RequireNatDet', 'Value'=>'Yes' ) ) ), 'AlarmScore'=>array( 'Type'=>'integer', 'Min'=>'1', 'Max'=>'100', 'Value'=>'99', 'Require'=>array( array( 'Name'=>'Enabled', 'Value'=>'Yes' ) ) ) ); $pOptions=$generalOptions; $optionNames=array(); if(file_exists($plugin_path."/config.php")) { include_once($plugin_path."/config.php"); 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' ) ); } elseif(is_array($optionValue['Require'])) { $optionValue['Require'][] = array ( 'Name'=>'Enabled', 'Value'=>'Yes' ); } else { // Wrong type continue; } $pOptions[$optionKey]=$optionValue; } } $sql='SELECT * FROM PluginsConfig WHERE MonitorId=? AND ZoneId=? AND pluginName=?'; foreach( dbFetchAll( $sql, NULL, array( $mid, $zid, $plugin ) ) as $popt ) { if(array_key_exists($popt['Name'], $pOptions) && $popt['Type']==$pOptions[$popt['Name']]['Type']) { array_push($optionNames, $popt['Name']); // Backup dependency information $require = ''; if(isset($pOptions[$popt['Name']]['Require'])) $require = $pOptions[$popt['Name']]['Require']; // Set value from database $pOptions[$popt['Name']]=$popt; // Restore dependancy information from backup if(!empty($require)) $pOptions[$popt['Name']]['Require'] = $require; // Set default dependancy information if not set in configuration else if($popt['Name'] != 'Enabled') $pOptions[$popt['Name']]['Require'] = array ( array( 'Name'=>'Enabled', 'Value'=>'Yes' ) ); } else { dbQuery('DELETE FROM PluginsConfig WHERE Id=?', array( $popt['Id'] ) ); } } // Add option in database if missing foreach($pOptions as $key => $popt) { if(!in_array($key, $optionNames)) { switch($popt['Type']) { case "select": $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,?,'','',?,?,?)"; dbQuery($sql, array( $key, $popt['Value'], $popt['Type'], $popt['Choices'], $mid, $zid, $plugin ) ); break; case "integer": $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,'',?,?,?,?,?)"; dbQuery($sql, array( $key, $popt['Value'], $popt['Type'], $popt['Min'], $popt['Max'], $mid, $zid, $plugin ) ); break; case "list": $sql="INSERT INTO PluginsConfig VALUES ('',?,'',?,'','','',?,?,?)"; dbQuery($sql, array( $key, $popt['Type'], $mid, $zid, $plugin ) ); break; case "checkbox": case "text": default: $sql="INSERT INTO PluginsConfig VALUES ('',?,?,?,'','','',?,?,?)"; dbQuery($sql, array( $key, $popt['Value'], $popt['Type'], $mid, $zid, $plugin ) ); } } } $PLANG=array(); $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); } } } function pLang($name) { global $SLANG; global $PLANG; if(array_key_exists($name, $SLANG)) return $SLANG[$name]; else if(array_key_exists($name, $PLANG)) return $PLANG[$name]; else return $name; } function isEnabled($param) { global $pOptions; $option = $pOptions[$param]; if (!isset($option['Require'])) return true; foreach($option['Require'] as $req_couple) { $name = $req_couple['Name']; if (!array_key_exists($name, $pOptions)) continue; if ($req_couple['Value'] != $pOptions[$name]['Value']) return false; } return true; } xhtmlHeaders(__FILE__, $SLANG['Plugin'] ); ?>
$popt) { ?> "; } ?>
onchange="applyChanges();"> "> onchange="applyChanges();"> >
onkeyup="updateAddBtn('');" />
/>
disabled="disabled"/>