Passed
Push — master ( 6a1f5a...b100fb )
by Patrick
02:54
created
library/Trapdirector/Config/TrapModuleConfig.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@  discard block
 block discarded – undo
4 4
 
5 5
 class TrapModuleConfig
6 6
 {
7
-    /********** Database configuration ***********************/
7
+	/********** Database configuration ***********************/
8 8
 	// Database prefix for tables 
9
-    protected $table_prefix; //< Database prefix for tables 	
9
+	protected $table_prefix; //< Database prefix for tables 	
10 10
 	protected $DBConfigDefaults=array(
11 11
 		'db_remove_days' => 60, // number of days before removing traps
12 12
 		'log_destination' => 'syslog', // Log destination for trap handler
13 13
 		'log_file' => '/tmp/trapdirector.log', // Log file
14 14
 		'log_level' => 2, // log level
15 15
 		'use_SnmpTrapAddess' => 1, // use SnmpTrapAddress by default
16
-	    'SnmpTrapAddess_oid' => '.1.3.6.1.6.3.18.1.3', // default snmpTrapAdress OID
16
+		'SnmpTrapAddess_oid' => '.1.3.6.1.6.3.18.1.3', // default snmpTrapAdress OID
17 17
 	);
18 18
 	// get default values for dbconfig
19 19
 	public function getDBConfigDefaults() { return $this->DBConfigDefaults;}
@@ -120,27 +120,27 @@  discard block
 block discarded – undo
120 120
 	// Note : must have 'source_ip' and 'last_sent'
121 121
 	public function getTrapHostListDisplayColumns()
122 122
 	{
123
-	    return array(
124
-	        'source_name'  =>  't.source_name',
125
-	        'source_ip'    =>  't.source_ip',
126
-	        'trap_oid'     =>  't.trap_oid',
127
-	        'count'        =>  'count(*)',
128
-	        'last_sent'    =>  'UNIX_TIMESTAMP(max(t.date_received))'
129
-	    );
123
+		return array(
124
+			'source_name'  =>  't.source_name',
125
+			'source_ip'    =>  't.source_ip',
126
+			'trap_oid'     =>  't.trap_oid',
127
+			'count'        =>  'count(*)',
128
+			'last_sent'    =>  'UNIX_TIMESTAMP(max(t.date_received))'
129
+		);
130 130
 	}
131 131
 
132 132
 	public function getTrapHostListSearchColumns()
133 133
 	{
134
-	    return array(); // No search needed on this table
134
+		return array(); // No search needed on this table
135 135
 	}
136 136
 	// Titles display in Trap List table
137 137
 	public function getTrapHostListTitles()
138 138
 	{
139
-	    return array(
140
-	        'trap_oid'		=> 'Trap OID',
141
-	        'count'		    => 'Number of traps received',
142
-	        'last_sent'     => 'Last trap received'
143
-	    );
139
+		return array(
140
+			'trap_oid'		=> 'Trap OID',
141
+			'count'		    => 'Number of traps received',
142
+			'last_sent'     => 'Last trap received'
143
+		);
144 144
 	}
145 145
 	
146 146
 	
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 			'revert_ok'		=> 'r.revert_ok',
196 196
 			'display'		=> 'r.display',
197 197
 			'modified'		=> 'UNIX_TIMESTAMP(r.modified)',
198
-            'modifier'		=> 'r.modifier'
198
+			'modifier'		=> 'r.modifier'
199 199
 		);
200 200
 	}	
201 201
 		
Please login to merge, or discard this patch.
library/Trapdirector/TrapsProcess/TrapConfig.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -15,184 +15,184 @@
 block discarded – undo
15 15
 trait TrapConfig
16 16
 {
17 17
 
18
-    /** @return \Trapdirector\Logging   */
19
-    abstract public function getLogging();
20
-    /** @return \Trapdirector\TrapApi   */
21
-    abstract public function getTrapApi();
18
+	/** @return \Trapdirector\Logging   */
19
+	abstract public function getLogging();
20
+	/** @return \Trapdirector\TrapApi   */
21
+	abstract public function getTrapApi();
22 22
     
23
-    /**
24
-     * Get option from array of ini file, send message if empty
25
-     * @param string $option_array Array of ini file
26
-     * @param string $option_category category in ini file
27
-     * @param string $option_name name of option in category
28
-     * @param mixed $option_var variable to fill if found, left untouched if not found
29
-     * @param integer $log_level default 2 (warning)
30
-     * @param string $message warning message if not found
31
-     * @return boolean true if found, or false
32
-     */
33
-    protected function getOptionIfSet($option_array,$option_category,$option_name, &$option_var, $log_level = WARN, $message = null)
34
-    {
35
-        if (!isset($option_array[$option_category][$option_name]))
36
-        {
37
-            if ($message === null)
38
-            {
39
-                $message='No ' . $option_name . ' in config file: '. $this->trapModuleConfig;
40
-            }
41
-            $this->getLogging()->log($message,$log_level);
42
-            return false;
43
-        }
44
-        else
45
-        {
46
-            $option_var=$option_array[$option_category][$option_name];
47
-            return true;
48
-        }
49
-    }
23
+	/**
24
+	 * Get option from array of ini file, send message if empty
25
+	 * @param string $option_array Array of ini file
26
+	 * @param string $option_category category in ini file
27
+	 * @param string $option_name name of option in category
28
+	 * @param mixed $option_var variable to fill if found, left untouched if not found
29
+	 * @param integer $log_level default 2 (warning)
30
+	 * @param string $message warning message if not found
31
+	 * @return boolean true if found, or false
32
+	 */
33
+	protected function getOptionIfSet($option_array,$option_category,$option_name, &$option_var, $log_level = WARN, $message = null)
34
+	{
35
+		if (!isset($option_array[$option_category][$option_name]))
36
+		{
37
+			if ($message === null)
38
+			{
39
+				$message='No ' . $option_name . ' in config file: '. $this->trapModuleConfig;
40
+			}
41
+			$this->getLogging()->log($message,$log_level);
42
+			return false;
43
+		}
44
+		else
45
+		{
46
+			$option_var=$option_array[$option_category][$option_name];
47
+			return true;
48
+		}
49
+	}
50 50
 
51
-    /**
52
-     * Get options in database
53
-     */
54
-    protected function getDatabaseOptions()
55
-    {
56
-        // Database options
57
-        if ($this->logSetup === false) // Only if logging was no setup in constructor
58
-        {
59
-            $this->getDBConfigIfSet('log_level',$this->getLogging()->debugLevel);
60
-            $this->getDBConfigIfSet('log_destination',$this->getLogging()->outputMode);
61
-            $this->getDBConfigIfSet('log_file',$this->getLogging()->outputFile);
62
-        }
63
-    }
51
+	/**
52
+	 * Get options in database
53
+	 */
54
+	protected function getDatabaseOptions()
55
+	{
56
+		// Database options
57
+		if ($this->logSetup === false) // Only if logging was no setup in constructor
58
+		{
59
+			$this->getDBConfigIfSet('log_level',$this->getLogging()->debugLevel);
60
+			$this->getDBConfigIfSet('log_destination',$this->getLogging()->outputMode);
61
+			$this->getDBConfigIfSet('log_file',$this->getLogging()->outputFile);
62
+		}
63
+	}
64 64
         
65
-    /** Set $variable to value if $element found in database config table
66
-     * @param string $element
67
-     * @param string $variable
68
-     */
69
-    protected function getDBConfigIfSet($element,&$variable)
70
-    {
71
-        $value=$this->getDBConfig($element);
72
-        if ($value != null) $variable=$value;
73
-    }
65
+	/** Set $variable to value if $element found in database config table
66
+	 * @param string $element
67
+	 * @param string $variable
68
+	 */
69
+	protected function getDBConfigIfSet($element,&$variable)
70
+	{
71
+		$value=$this->getDBConfig($element);
72
+		if ($value != null) $variable=$value;
73
+	}
74 74
     
75
-    /**
76
-     *   Get data from db_config
77
-     *	@param $element string name of param
78
-     *	@return mixed : value (or null)
79
-     */
80
-    protected function getDBConfig($element)  // TODO : put this in DB class
81
-    {
82
-        $db_conn=$this->trapsDB->db_connect_trap();
83
-        $sql='SELECT value from '.$this->dbPrefix.'db_config WHERE ( name=\''.$element.'\' )';
84
-        if (($ret_code=$db_conn->query($sql)) === false) {
85
-            $this->logging->log('No result in query : ' . $sql,WARN,'');
86
-            return null;
87
-        }
88
-        $value=$ret_code->fetch();
89
-        if ($value != null && isset($value['value']))
90
-        {
91
-            return $value['value'];
92
-        }
93
-        return null;
94
-    }
75
+	/**
76
+	 *   Get data from db_config
77
+	 *	@param $element string name of param
78
+	 *	@return mixed : value (or null)
79
+	 */
80
+	protected function getDBConfig($element)  // TODO : put this in DB class
81
+	{
82
+		$db_conn=$this->trapsDB->db_connect_trap();
83
+		$sql='SELECT value from '.$this->dbPrefix.'db_config WHERE ( name=\''.$element.'\' )';
84
+		if (($ret_code=$db_conn->query($sql)) === false) {
85
+			$this->logging->log('No result in query : ' . $sql,WARN,'');
86
+			return null;
87
+		}
88
+		$value=$ret_code->fetch();
89
+		if ($value != null && isset($value['value']))
90
+		{
91
+			return $value['value'];
92
+		}
93
+		return null;
94
+	}
95 95
     
96
-    /**
97
-     * Get options from ini file
98
-     * @param array $trap_config : ini file array
99
-     */
100
-    protected function getMainOptions($trapConfig)
101
-    {
96
+	/**
97
+	 * Get options from ini file
98
+	 * @param array $trap_config : ini file array
99
+	 */
100
+	protected function getMainOptions($trapConfig)
101
+	{
102 102
         
103
-        $nodeStatus='';
104
-        $this->getOptionIfSet($trapConfig,'config','node', $nodeStatus);
105
-        if ($this->getTrapApi()->setStatus($nodeStatus) === FALSE)
106
-        {
107
-            $this->getLogging()->log('Unknown node status '.$nodeStatus.' : setting to MASTER',WARN);
108
-            $this->getTrapApi()->setStatusMaster();
109
-        }
110
-        else 
111
-        {
112
-            if ($this->getTrapApi()->getStatus() != TrapApi::MASTER)
113
-            {
114
-                // Get options to connect to API
115
-                $IP = $port = $user =  $pass = null;
116
-                $this->getOptionIfSet($trapConfig,'config','masterIP', $IP, ERROR);
117
-                $this->getOptionIfSet($trapConfig,'config','masterPort', $port, ERROR);
118
-                $this->getOptionIfSet($trapConfig,'config','masterUser', $user, ERROR);
119
-                $this->getOptionIfSet($trapConfig,'config','masterPass', $pass, ERROR);
120
-                $this->getTrapApi()->setParams($IP, $port, $user, $pass);
121
-                return;
122
-            }
123
-        }
103
+		$nodeStatus='';
104
+		$this->getOptionIfSet($trapConfig,'config','node', $nodeStatus);
105
+		if ($this->getTrapApi()->setStatus($nodeStatus) === FALSE)
106
+		{
107
+			$this->getLogging()->log('Unknown node status '.$nodeStatus.' : setting to MASTER',WARN);
108
+			$this->getTrapApi()->setStatusMaster();
109
+		}
110
+		else 
111
+		{
112
+			if ($this->getTrapApi()->getStatus() != TrapApi::MASTER)
113
+			{
114
+				// Get options to connect to API
115
+				$IP = $port = $user =  $pass = null;
116
+				$this->getOptionIfSet($trapConfig,'config','masterIP', $IP, ERROR);
117
+				$this->getOptionIfSet($trapConfig,'config','masterPort', $port, ERROR);
118
+				$this->getOptionIfSet($trapConfig,'config','masterUser', $user, ERROR);
119
+				$this->getOptionIfSet($trapConfig,'config','masterPass', $pass, ERROR);
120
+				$this->getTrapApi()->setParams($IP, $port, $user, $pass);
121
+				return;
122
+			}
123
+		}
124 124
         
125
-        // Snmptranslate binary path
126
-        $this->getOptionIfSet($trapConfig,'config','snmptranslate', $this->snmptranslate);
125
+		// Snmptranslate binary path
126
+		$this->getOptionIfSet($trapConfig,'config','snmptranslate', $this->snmptranslate);
127 127
         
128
-        // mibs path
129
-        $this->getOptionIfSet($trapConfig,'config','snmptranslate_dirs', $this->snmptranslate_dirs);
128
+		// mibs path
129
+		$this->getOptionIfSet($trapConfig,'config','snmptranslate_dirs', $this->snmptranslate_dirs);
130 130
         
131
-        // icinga2cmd path
132
-        $this->getOptionIfSet($trapConfig,'config','icingacmd', $this->icinga2cmd);
131
+		// icinga2cmd path
132
+		$this->getOptionIfSet($trapConfig,'config','icingacmd', $this->icinga2cmd);
133 133
         
134
-        // table prefix
135
-        $this->getOptionIfSet($trapConfig,'config','database_prefix', $this->dbPrefix);
134
+		// table prefix
135
+		$this->getOptionIfSet($trapConfig,'config','database_prefix', $this->dbPrefix);
136 136
         
137
-        // API options
138
-        if ($this->getOptionIfSet($trapConfig,'config','icingaAPI_host', $this->apiHostname))
139
-        {
140
-            $this->apiUse=true;
141
-            // Get API options or throw exception as not configured correctly
142
-            $this->getOptionIfSet($trapConfig,'config','icingaAPI_port', $this->apiPort,ERROR);
143
-            $this->getOptionIfSet($trapConfig,'config','icingaAPI_user', $this->apiUsername,ERROR);
144
-            $this->getOptionIfSet($trapConfig,'config','icingaAPI_password', $this->apiPassword,ERROR);
145
-        }
146
-    }
137
+		// API options
138
+		if ($this->getOptionIfSet($trapConfig,'config','icingaAPI_host', $this->apiHostname))
139
+		{
140
+			$this->apiUse=true;
141
+			// Get API options or throw exception as not configured correctly
142
+			$this->getOptionIfSet($trapConfig,'config','icingaAPI_port', $this->apiPort,ERROR);
143
+			$this->getOptionIfSet($trapConfig,'config','icingaAPI_user', $this->apiUsername,ERROR);
144
+			$this->getOptionIfSet($trapConfig,'config','icingaAPI_password', $this->apiPassword,ERROR);
145
+		}
146
+	}
147 147
     
148
-    /**
149
-     * Create and setup database class for trap & ido (if no api) db
150
-     * @param array $trap_config : ini file array
151
-     */
152
-    protected function setupDatabase($trapConfig)
153
-    {
154
-        // Trap database
155
-        if (!array_key_exists('database',$trapConfig['config']))
156
-        {
157
-            $this->logging->log("No database in config file: ".$this->trapModuleConfig,ERROR,'');
158
-            return;
159
-        }
160
-        $dbTrapName=$trapConfig['config']['database'];
161
-        $this->logging->log("Found database in config file: ".$dbTrapName,INFO );
148
+	/**
149
+	 * Create and setup database class for trap & ido (if no api) db
150
+	 * @param array $trap_config : ini file array
151
+	 */
152
+	protected function setupDatabase($trapConfig)
153
+	{
154
+		// Trap database
155
+		if (!array_key_exists('database',$trapConfig['config']))
156
+		{
157
+			$this->logging->log("No database in config file: ".$this->trapModuleConfig,ERROR,'');
158
+			return;
159
+		}
160
+		$dbTrapName=$trapConfig['config']['database'];
161
+		$this->logging->log("Found database in config file: ".$dbTrapName,INFO );
162 162
         
163
-        if ( ($dbConfig=parse_ini_file($this->icingaweb2Ressources,true)) === false)
164
-        {
165
-            $this->logging->log("Error reading ini file : ".$this->icingaweb2Ressources,ERROR,'');
166
-            return;
167
-        }
168
-        if (!array_key_exists($dbTrapName,$dbConfig))
169
-        {
170
-            $this->logging->log("No database '.$dbTrapName.' in config file: ".$this->icingaweb2Ressources,ERROR,'');
171
-            return;
172
-        }
163
+		if ( ($dbConfig=parse_ini_file($this->icingaweb2Ressources,true)) === false)
164
+		{
165
+			$this->logging->log("Error reading ini file : ".$this->icingaweb2Ressources,ERROR,'');
166
+			return;
167
+		}
168
+		if (!array_key_exists($dbTrapName,$dbConfig))
169
+		{
170
+			$this->logging->log("No database '.$dbTrapName.' in config file: ".$this->icingaweb2Ressources,ERROR,'');
171
+			return;
172
+		}
173 173
         
174
-        $this->trapsDB = new Database($this->logging,$dbConfig[$dbTrapName],$this->dbPrefix);
174
+		$this->trapsDB = new Database($this->logging,$dbConfig[$dbTrapName],$this->dbPrefix);
175 175
         
176
-        $this->logging->log("API Use : ".print_r($this->apiUse,true),DEBUG );
176
+		$this->logging->log("API Use : ".print_r($this->apiUse,true),DEBUG );
177 177
         
178
-        //TODO enable this again when API queries are all done :
179
-        //if ($this->apiUse === true) return; // In case of API use, no IDO is necessary
178
+		//TODO enable this again when API queries are all done :
179
+		//if ($this->apiUse === true) return; // In case of API use, no IDO is necessary
180 180
         
181
-        // IDO Database
182
-        if (!array_key_exists('IDOdatabase',$trapConfig['config']))
183
-        {
184
-            $this->logging->log("No IDOdatabase in config file: ".$this->trapModuleConfig,ERROR,'');
185
-        }
186
-        $dbIdoName=$trapConfig['config']['IDOdatabase'];
181
+		// IDO Database
182
+		if (!array_key_exists('IDOdatabase',$trapConfig['config']))
183
+		{
184
+			$this->logging->log("No IDOdatabase in config file: ".$this->trapModuleConfig,ERROR,'');
185
+		}
186
+		$dbIdoName=$trapConfig['config']['IDOdatabase'];
187 187
         
188
-        $this->logging->log("Found IDO database in config file: ".$dbIdoName,INFO );
189
-        if (!array_key_exists($dbIdoName,$dbConfig))
190
-        {
191
-            $this->logging->log("No database '.$dbIdoName.' in config file: ".$this->icingaweb2Ressources,ERROR,'');
192
-            return;
193
-        }
188
+		$this->logging->log("Found IDO database in config file: ".$dbIdoName,INFO );
189
+		if (!array_key_exists($dbIdoName,$dbConfig))
190
+		{
191
+			$this->logging->log("No database '.$dbIdoName.' in config file: ".$this->icingaweb2Ressources,ERROR,'');
192
+			return;
193
+		}
194 194
         
195
-        $this->trapsDB->setupIDO($dbConfig[$dbIdoName]);
196
-    }
195
+		$this->trapsDB->setupIDO($dbConfig[$dbIdoName]);
196
+	}
197 197
     
198 198
 }
199 199
\ No newline at end of file
Please login to merge, or discard this patch.
application/controllers/StatusController.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 		/************  Trapdb ***********/
22 22
 		try
23 23
 		{
24
-		    $dbConn = $this->getUIDatabase()->getDbConn();
25
-		    if ($dbConn === null) throw new \ErrorException('uncatched db error');
24
+			$dbConn = $this->getUIDatabase()->getDbConn();
25
+			if ($dbConn === null) throw new \ErrorException('uncatched db error');
26 26
 			$query = $dbConn->select()->from(
27 27
 				$this->getModuleConfig()->getTrapTableName(),
28 28
 				array('COUNT(*)')
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		
52 52
 		try
53 53
 		{		
54
-		    $this->view->currentLogDestination=$this->getUIDatabase()->getDBConfigValue('log_destination');
54
+			$this->view->currentLogDestination=$this->getUIDatabase()->getDBConfigValue('log_destination');
55 55
 			$this->view->logDestinations=$this->getModuleConfig()->getLogDestinations();
56 56
 			$this->view->currentLogFile=$this->getUIDatabase()->getDBConfigValue('log_file');
57 57
 			$this->view->logLevels=$this->getModuleConfig()->getlogLevels();
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
 		/*************** SNMP configuration ****************/
66 66
 		try
67 67
 		{
68
-		    $this->view->useSnmpTrapAddess= ( $this->getUIDatabase()->getDBConfigValue('use_SnmpTrapAddess') == 1 ) ? TRUE : FALSE;
69
-		    $this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid');
70
-		    $this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE;
68
+			$this->view->useSnmpTrapAddess= ( $this->getUIDatabase()->getDBConfigValue('use_SnmpTrapAddess') == 1 ) ? TRUE : FALSE;
69
+			$this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid');
70
+			$this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE;
71 71
 		    
72 72
 		}
73 73
 		catch (Exception $e)
74 74
 		{
75
-		    $this->displayExitError('status',$e->getMessage());
75
+			$this->displayExitError('status',$e->getMessage());
76 76
 		}		
77 77
 		
78 78
 	} 
79 79
   
80 80
 	/** Mib management
81
-	*	Post param : action=update_mib_db : update mib database
82
-	*	Post param : ation=check_update : check if mib update is finished
83
-	*	File post : mibfile -> save mib file
84
-	*/
81
+	 *	Post param : action=update_mib_db : update mib database
82
+	 *	Post param : ation=check_update : check if mib update is finished
83
+	 *	File post : mibfile -> save mib file
84
+	 */
85 85
 	public function mibAction()
86 86
 	{
87 87
 		$this->prepareTabs()->activate('mib');
@@ -100,22 +100,22 @@  discard block
 block discarded – undo
100 100
 					$return=exec('icingacli trapdirector mib update --pid /tmp/trapdirector_update.pid');
101 101
 					if (preg_match('/OK/',$return))
102 102
 					{
103
-					    $this->_helper->json(array('status'=>'OK'));
103
+						$this->_helper->json(array('status'=>'OK'));
104 104
 					}
105 105
 					// Error
106 106
 					$this->_helper->json(array('status'=>$return));
107 107
 				}
108 108
 				if ($action == 'check_update')
109 109
 				{
110
-				    $file=@fopen('/tmp/trapdirector_update.pid','r');
111
-				    if ($file == false)
112
-				    {   // process is dead
113
-				        $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file'));
114
-				        return;
115
-				    }
116
-				    $pid=fgets($file);
117
-				    $output=array();
118
-				    $retVal=0;
110
+					$file=@fopen('/tmp/trapdirector_update.pid','r');
111
+					if ($file == false)
112
+					{   // process is dead
113
+						$this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file'));
114
+						return;
115
+					}
116
+					$pid=fgets($file);
117
+					$output=array();
118
+					$retVal=0;
119 119
 					exec('ps '.$pid,$output,$retVal);
120 120
 					if ($retVal == 0)
121 121
 					{ // process is alive
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 					}
124 124
 					else
125 125
 					{ // process is dead
126
-					    $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid));
126
+						$this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid));
127 127
 					}
128 128
 				}
129 129
 				$this->_helper->json(array('status'=>'ERR : no '.$action.' action possible' ));
@@ -131,32 +131,32 @@  discard block
 block discarded – undo
131 131
 			/** Check for mib file UPLOAD */
132 132
 			if (isset($_FILES['mibfile']))
133 133
 			{
134
-			    $name=filter_var($_FILES['mibfile']['name'],FILTER_SANITIZE_STRING);
134
+				$name=filter_var($_FILES['mibfile']['name'],FILTER_SANITIZE_STRING);
135 135
 				$DirConf=explode(':',$this->Config()->get('config', 'snmptranslate_dirs'));
136 136
 				$destDir=array_shift($DirConf);
137 137
 				if (!is_dir($destDir))
138 138
 				{
139
-				    $this->view->uploadStatus="ERROR : no $destDir directory, check module configuration";
139
+					$this->view->uploadStatus="ERROR : no $destDir directory, check module configuration";
140 140
 				}
141 141
 				else
142 142
 				{
143
-				    if (!is_writable($destDir))
144
-				    {
145
-				        $this->view->uploadStatus="ERROR : $destDir directory is not writable";
146
-				    }
147
-				    else
148
-				    {
149
-				        $destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name";
150
-				        $sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'],FILTER_SANITIZE_STRING);
151
-				        if (move_uploaded_file($sourceTmpNam,$destination)===false)
152
-    				    {
153
-    				        $this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations";
154
-    				    }
155
-    				    else
156
-    				    {
157
-    				        $this->view->uploadStatus="File $name uploaded in $destDir";
158
-    				    }
159
-				    }
143
+					if (!is_writable($destDir))
144
+					{
145
+						$this->view->uploadStatus="ERROR : $destDir directory is not writable";
146
+					}
147
+					else
148
+					{
149
+						$destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name";
150
+						$sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'],FILTER_SANITIZE_STRING);
151
+						if (move_uploaded_file($sourceTmpNam,$destination)===false)
152
+						{
153
+							$this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations";
154
+						}
155
+						else
156
+						{
157
+							$this->view->uploadStatus="File $name uploaded in $destDir";
158
+						}
159
+					}
160 160
 				}
161 161
 
162 162
 			}
@@ -276,47 +276,47 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	public function pluginsAction()
278 278
 	{
279
-	    $this->prepareTabs()->activate('plugins');
279
+		$this->prepareTabs()->activate('plugins');
280 280
 	    
281
-	    require_once($this->Module()->getBaseDir() .'/bin/trap_class.php');
282
-	    $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc');
283
-	    $Trap = new Trap($icingaweb2_etc,4);
281
+		require_once($this->Module()->getBaseDir() .'/bin/trap_class.php');
282
+		$icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc');
283
+		$Trap = new Trap($icingaweb2_etc,4);
284 284
 	    
285
-	    $this->view->pluginLoaded = htmlentities($Trap->pluginClass->registerAllPlugins(false));
285
+		$this->view->pluginLoaded = htmlentities($Trap->pluginClass->registerAllPlugins(false));
286 286
 	    
287
-	    $enabledPlugins = $Trap->pluginClass->getEnabledPlugins();
287
+		$enabledPlugins = $Trap->pluginClass->getEnabledPlugins();
288 288
 
289
-	    $pluginList = $Trap->pluginClass->pluginList();
289
+		$pluginList = $Trap->pluginClass->pluginList();
290 290
 	    
291
-	    // Plugin list and fill function name list
292
-	    $functionList=array();
293
-	    $this->view->pluginArray=array();
294
-	    foreach ($pluginList as $plugin)
295
-	    {
296
-	        $pluginDetails=$Trap->pluginClass->pluginDetails($plugin);
297
-	        $pluginDetails->enabled =  (in_array($plugin, $enabledPlugins)) ? true : false;
298
-	        $pluginDetails->catchAllTraps = ($pluginDetails->catchAllTraps === true )? 'Yes' : 'No';
299
-	        $pluginDetails->processTraps = ($pluginDetails->processTraps === true )? 'Yes' : 'No';
300
-	        $pluginDetails->description = htmlentities($pluginDetails->description);
301
-	        $pluginDetails->description = preg_replace('/\n/','<br>',$pluginDetails->description);
302
-	        array_push($this->view->pluginArray, $pluginDetails);
303
-	        // Get functions for function details
304
-	        foreach ($pluginDetails->funcArray as $function)
305
-	        {
306
-	            array_push($functionList,$function);
307
-	        }
308
-	    }
291
+		// Plugin list and fill function name list
292
+		$functionList=array();
293
+		$this->view->pluginArray=array();
294
+		foreach ($pluginList as $plugin)
295
+		{
296
+			$pluginDetails=$Trap->pluginClass->pluginDetails($plugin);
297
+			$pluginDetails->enabled =  (in_array($plugin, $enabledPlugins)) ? true : false;
298
+			$pluginDetails->catchAllTraps = ($pluginDetails->catchAllTraps === true )? 'Yes' : 'No';
299
+			$pluginDetails->processTraps = ($pluginDetails->processTraps === true )? 'Yes' : 'No';
300
+			$pluginDetails->description = htmlentities($pluginDetails->description);
301
+			$pluginDetails->description = preg_replace('/\n/','<br>',$pluginDetails->description);
302
+			array_push($this->view->pluginArray, $pluginDetails);
303
+			// Get functions for function details
304
+			foreach ($pluginDetails->funcArray as $function)
305
+			{
306
+				array_push($functionList,$function);
307
+			}
308
+		}
309 309
 	    
310
-	    // Function list with details
311
-	    $this->view->functionList=array();
312
-	    foreach ($functionList as $function)
313
-	    {
314
-	        $functionDetail = $Trap->pluginClass->getFunctionDetails($function);
315
-	        $functionDetail->params = htmlentities($functionDetail->params);
316
-	        $functionDetail->description = htmlentities($functionDetail->description);
317
-	        $functionDetail->description = preg_replace('/\n/','<br>',$functionDetail->description);
318
-	        array_push($this->view->functionList, $functionDetail);
319
-	    }
310
+		// Function list with details
311
+		$this->view->functionList=array();
312
+		foreach ($functionList as $function)
313
+		{
314
+			$functionDetail = $Trap->pluginClass->getFunctionDetails($function);
315
+			$functionDetail->params = htmlentities($functionDetail->params);
316
+			$functionDetail->description = htmlentities($functionDetail->description);
317
+			$functionDetail->description = preg_replace('/\n/','<br>',$functionDetail->description);
318
+			array_push($this->view->functionList, $functionDetail);
319
+		}
320 320
 
321 321
 	}
322 322
 	
@@ -331,30 +331,30 @@  discard block
 block discarded – undo
331 331
 		)->add('services', array(
332 332
 			'label' => $this->translate('Services management'),
333 333
 			'url'   => $this->getModuleConfig()->urlPath() . '/status/services')
334
-	    )->add('plugins', array(
335
-	        'label' => $this->translate('Plugins management'),
336
-	        'url'   => $this->getModuleConfig()->urlPath() . '/status/plugins')
337
-	    );
334
+		)->add('plugins', array(
335
+			'label' => $this->translate('Plugins management'),
336
+			'url'   => $this->getModuleConfig()->urlPath() . '/status/plugins')
337
+		);
338 338
 	} 
339 339
 }
340 340
 
341 341
 // TODO : see if useless 
342 342
 class UploadForm extends Form
343 343
 { 
344
-    public function __construct($options = null) 
345
-    {
346
-        parent::__construct($options);
347
-        $this->addElements2();
348
-    }
344
+	public function __construct($options = null) 
345
+	{
346
+		parent::__construct($options);
347
+		$this->addElements2();
348
+	}
349 349
 
350
-    public function addElements2()
351
-    {
352
-        // File Input
353
-        $file = new File('mib-file');
354
-        $file->setLabel('Mib upload');
355
-             //->setAttrib('multiple', null);
356
-        $this->addElement($file);
350
+	public function addElements2()
351
+	{
352
+		// File Input
353
+		$file = new File('mib-file');
354
+		$file->setLabel('Mib upload');
355
+			 //->setAttrib('multiple', null);
356
+		$this->addElement($file);
357 357
 		$button = new Submit("upload",array('ignore'=>false));
358 358
 		$this->addElement($button);//->setIgnore(false);
359
-    }
359
+	}
360 360
 }
Please login to merge, or discard this patch.
application/controllers/HelperController.php 1 patch
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 {
13 13
 	
14 14
 	/** Get host list with filter (IP or name) : host=<filter>
15
-	*	returns in JSON : status=>OK/NOK  hosts=>array of hosts
16
-	*/
15
+	 *	returns in JSON : status=>OK/NOK  hosts=>array of hosts
16
+	 */
17 17
 	public function gethostsAction()
18 18
 	{
19 19
 		$postData=$this->getRequest()->getPost();
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 	
34 34
 	/** Get hostgroup list with filter (name) : hostgroup=<hostFilter>
35
-	*	returns in JSON : status=>OK/NOK  hosts=>array of hosts
36
-	*/
35
+	 *	returns in JSON : status=>OK/NOK  hosts=>array of hosts
36
+	 */
37 37
 	public function gethostgroupsAction()
38 38
 	{
39 39
 		$postData=$this->getRequest()->getPost();
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 	
54 54
 	/** Get service list by host name ( host=<host> )
55
-	*	returns in JSON : 
56
-	*		status=>OK/No services found/More than one host matches
57
-	*		services=>array of services (name)
58
-	*		hostid = host object id or -1 if not found.
59
-	*/
55
+	 *	returns in JSON : 
56
+	 *		status=>OK/No services found/More than one host matches
57
+	 *		services=>array of services (name)
58
+	 *		hostid = host object id or -1 if not found.
59
+	 */
60 60
 	public function getservicesAction()
61 61
 	{
62 62
 		$postData=$this->getRequest()->getPost();
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 	
100 100
 	/** Get service list by host group ( name=<host> )
101
-	*	returns in JSON : 
102
-	*		status=>OK/No services found/More than one host matches
103
-	*		services=>array of services (name)
104
-	*		groupid = group object id or -1 if not found.
105
-	*/
101
+	 *	returns in JSON : 
102
+	 *		status=>OK/No services found/More than one host matches
103
+	 *		services=>array of services (name)
104
+	 *		groupid = group object id or -1 if not found.
105
+	 */
106 106
 	public function gethostgroupservicesAction()
107 107
 	{
108 108
 		$postData=$this->getRequest()->getPost();
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 	}
133 133
 
134 134
 	/** Get traps from mib  : entry : mib=<mib>
135
-	*	returns in JSON : 
136
-	*		status=>OK/No mib/Error getting mibs
137
-	*		traps=>array of array( oid -> name)
138
-	*/
135
+	 *	returns in JSON : 
136
+	 *		status=>OK/No mib/Error getting mibs
137
+	 *		traps=>array of array( oid -> name)
138
+	 */
139 139
 	public function gettrapsAction()
140 140
 	{
141 141
 		$postData=$this->getRequest()->getPost();
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 	}	
156 156
 
157 157
 	/** Get trap objects from mib  : entry : trap=<oid>
158
-	*	returns in JSON : 
159
-	*		status=>OK/no trap/not found
160
-	*		objects=>array of array( oid -> name, oid->mib)
161
-	*/
158
+	 *	returns in JSON : 
159
+	 *		status=>OK/no trap/not found
160
+	 *		objects=>array of array( oid -> name, oid->mib)
161
+	 */
162 162
 	public function gettrapobjectsAction()
163 163
 	{
164 164
 		$postData=$this->getRequest()->getPost();
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 	}	
179 179
 	
180 180
 	/** Get list of all loaded mibs : entry : none
181
-	*	return : array of strings.
182
-	*/
181
+	 *	return : array of strings.
182
+	 */
183 183
 	public function getmiblistAction()
184 184
 	{
185 185
 		try
@@ -194,10 +194,10 @@  discard block
 block discarded – undo
194 194
 	}
195 195
 	
196 196
 	/** Get MIB::Name from OID : entry : oid
197
-	*		status=>OK/No oid/not found
198
-	*		mib=>string
199
-	*		name=>string
200
-	*/	
197
+	 *		status=>OK/No oid/not found
198
+	 *		mib=>string
199
+	 *		name=>string
200
+	 */	
201 201
 	public function translateoidAction()
202 202
 	{
203 203
 		$postData=$this->getRequest()->getPost();
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 					'name' => $object['name'],
219 219
 					'type' => $object['type'],
220 220
 					'type_enum' => $object['type_enum'],
221
-				    'description' => $object['description']
221
+					'description' => $object['description']
222 222
 				)
223 223
 			);
224 224
 		}
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 	}
227 227
 	
228 228
 	/** Save or execute database purge of <n> days
229
-	*	days=>int 
230
-	*	action=>save/execute
231
-	*	return : status=>OK/Message error
232
-	*/
229
+	 *	days=>int 
230
+	 *	action=>save/execute
231
+	 *	return : status=>OK/Message error
232
+	 */
233 233
 	public function dbmaintenanceAction()
234 234
 	{
235 235
 		
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 		{
245 245
 			try
246 246
 			{
247
-			    $this->getUIDatabase()->setDBConfigValue('db_remove_days',$days);
247
+				$this->getUIDatabase()->setDBConfigValue('db_remove_days',$days);
248 248
 			}
249 249
 			catch (Exception $e)
250 250
 			{
@@ -282,33 +282,33 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	public function snmpconfigAction()
284 284
 	{
285
-	    $postData=$this->getRequest()->getPost();
285
+		$postData=$this->getRequest()->getPost();
286 286
 	    
287
-	    $snmpUse = $this->checkPostVar($postData, 'useTrapAddr', '0|1');
287
+		$snmpUse = $this->checkPostVar($postData, 'useTrapAddr', '0|1');
288 288
 	    
289
-	    $snmpOID = $this->checkPostVar($postData, 'trapAddrOID', '^[\.0-9]+$');
289
+		$snmpOID = $this->checkPostVar($postData, 'trapAddrOID', '^[\.0-9]+$');
290 290
 	    	    
291
-	    try
292
-	    {
293
-	        $this->getUIDatabase()->setDBConfigValue('use_SnmpTrapAddess',$snmpUse);
294
-	        $this->getUIDatabase()->setDBConfigValue('SnmpTrapAddess_oid',$snmpOID);
295
-	    }
296
-	    catch (Exception $e)
297
-	    {
298
-	        $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() ));
299
-	        return;
300
-	    }
301
-	    $this->_helper->json(array('status'=>'OK'));
302
-	    return;
291
+		try
292
+		{
293
+			$this->getUIDatabase()->setDBConfigValue('use_SnmpTrapAddess',$snmpUse);
294
+			$this->getUIDatabase()->setDBConfigValue('SnmpTrapAddess_oid',$snmpOID);
295
+		}
296
+		catch (Exception $e)
297
+		{
298
+			$this->_helper->json(array('status'=>'Save error : '.$e->getMessage() ));
299
+			return;
300
+		}
301
+		$this->_helper->json(array('status'=>'OK'));
302
+		return;
303 303
 	    
304 304
 	}
305 305
 	
306 306
 	/** Save log output to db
307
-	*	destination=>log destination 
308
-	*	file=>file name
309
-	*	level => int 
310
-	*	return : status=>OK/Message error
311
-	*/
307
+	 *	destination=>log destination 
308
+	 *	file=>file name
309
+	 *	level => int 
310
+	 *	return : status=>OK/Message error
311
+	 */
312 312
 	public function logdestinationAction()
313 313
 	{
314 314
 		$postData=$this->getRequest()->getPost();
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 			$fileHandler=@fopen($file,'w');
328 328
 			if ($fileHandler == false)
329 329
 			{   // File os note writabe / cannot create
330
-			    $this->_helper->json(array('status'=>'File not writable :  '.$file));
331
-			    return;
330
+				$this->_helper->json(array('status'=>'File not writable :  '.$file));
331
+				return;
332 332
 			}
333 333
 		}
334 334
 		else
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 				
349 349
 		try
350 350
 		{
351
-		    $this->getUIDatabase()->setDBConfigValue('log_destination',$destination);
352
-		    $this->getUIDatabase()->setDBConfigValue('log_file',$file);
353
-		    $this->getUIDatabase()->setDBConfigValue('log_level',$level);
351
+			$this->getUIDatabase()->setDBConfigValue('log_destination',$destination);
352
+			$this->getUIDatabase()->setDBConfigValue('log_file',$file);
353
+			$this->getUIDatabase()->setDBConfigValue('log_level',$level);
354 354
 		}
355 355
 		catch (Exception $e)
356 356
 		{
@@ -370,33 +370,33 @@  discard block
 block discarded – undo
370 370
 	public function testruleAction()
371 371
 	{
372 372
 	    
373
-	    $postData=$this->getRequest()->getPost();
373
+		$postData=$this->getRequest()->getPost();
374 374
 	   
375
-	    $rule = $this->checkPostVar($postData, 'rule', '.*');
375
+		$rule = $this->checkPostVar($postData, 'rule', '.*');
376 376
 
377
-	    $action = $this->checkPostVar($postData, 'action', 'evaluate');
377
+		$action = $this->checkPostVar($postData, 'action', 'evaluate');
378 378
 
379
-	    if ($action == 'evaluate')
380
-	    {
381
-	        try
382
-	        {
383
-	            require_once($this->Module()->getBaseDir() .'/bin/trap_class.php');
384
-	            $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc');
385
-	            $trap = new Trap($icingaweb2_etc);
386
-	            // Cleanup spaces before eval
387
-	            $rule=$trap->ruleClass->eval_cleanup($rule);
388
-	            // Eval
389
-	            $item=0;
390
-	            $rule=$trap->ruleClass->evaluation($rule,$item);
391
-	        }
392
-	        catch (Exception $e)
393
-	        {
394
-	            $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() ));
395
-	            return;
396
-	        }
397
-	        $return=($rule==true)?'true':'false';
398
-	        $this->_helper->json(array('status'=>'OK', 'message' => $return));
399
-	    }
379
+		if ($action == 'evaluate')
380
+		{
381
+			try
382
+			{
383
+				require_once($this->Module()->getBaseDir() .'/bin/trap_class.php');
384
+				$icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc');
385
+				$trap = new Trap($icingaweb2_etc);
386
+				// Cleanup spaces before eval
387
+				$rule=$trap->ruleClass->eval_cleanup($rule);
388
+				// Eval
389
+				$item=0;
390
+				$rule=$trap->ruleClass->evaluation($rule,$item);
391
+			}
392
+			catch (Exception $e)
393
+			{
394
+				$this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() ));
395
+				return;
396
+			}
397
+			$return=($rule==true)?'true':'false';
398
+			$this->_helper->json(array('status'=>'OK', 'message' => $return));
399
+		}
400 400
 	    
401 401
 	}	
402 402
 
@@ -407,35 +407,35 @@  discard block
 block discarded – undo
407 407
 	 */
408 408
 	public function pluginAction()
409 409
 	{
410
-	    $postData=$this->getRequest()->getPost();
410
+		$postData=$this->getRequest()->getPost();
411 411
 	    
412
-	    $pluginName = $this->checkPostVar($postData, 'name', '.*');
412
+		$pluginName = $this->checkPostVar($postData, 'name', '.*');
413 413
 	    
414
-	    $action = $this->checkPostVar($postData, 'action', 'enable|disable');
414
+		$action = $this->checkPostVar($postData, 'action', 'enable|disable');
415 415
 	    
416
-        try
417
-        {
418
-            require_once($this->Module()->getBaseDir() .'/bin/trap_class.php');
419
-            $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc');
420
-            $trap = new Trap($icingaweb2_etc);
421
-            // Enable plugin.
422
-            $action=($action == 'enable') ? true : false;
423
-            $retVal=$trap->pluginClass->enablePlugin($pluginName, $action);
416
+		try
417
+		{
418
+			require_once($this->Module()->getBaseDir() .'/bin/trap_class.php');
419
+			$icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc');
420
+			$trap = new Trap($icingaweb2_etc);
421
+			// Enable plugin.
422
+			$action=($action == 'enable') ? true : false;
423
+			$retVal=$trap->pluginClass->enablePlugin($pluginName, $action);
424 424
             
425
-        }
426
-        catch (Exception $e)
427
-        {
428
-            $this->_helper->json(array('status'=>'Action error : '.$e->getMessage() ));
429
-            return;
430
-        }
431
-        if ($retVal === true)
432
-        {
433
-            $this->_helper->json(array('status'=>'OK'));
434
-        }
435
-        else
436
-        {
437
-            $this->_helper->json(array('status'=>'Error, see logs'));
438
-        }
425
+		}
426
+		catch (Exception $e)
427
+		{
428
+			$this->_helper->json(array('status'=>'Action error : '.$e->getMessage() ));
429
+			return;
430
+		}
431
+		if ($retVal === true)
432
+		{
433
+			$this->_helper->json(array('status'=>'OK'));
434
+		}
435
+		else
436
+		{
437
+			$this->_helper->json(array('status'=>'Error, see logs'));
438
+		}
439 439
 	}
440 440
 	
441 441
 	/** Function evaluation
@@ -445,49 +445,49 @@  discard block
 block discarded – undo
445 445
 	 */
446 446
 	public function functionAction()
447 447
 	{
448
-	    $postData=$this->getRequest()->getPost();
448
+		$postData=$this->getRequest()->getPost();
449 449
 	    
450
-	    $functionString = $this->checkPostVar($postData, 'function', '.*');
450
+		$functionString = $this->checkPostVar($postData, 'function', '.*');
451 451
 	    
452
-	    $this->checkPostVar($postData, 'action', 'evaluate');
452
+		$this->checkPostVar($postData, 'action', 'evaluate');
453 453
 	    
454
-	    // Only one action possible for now, no tests on action.
455
-	    try
456
-	    {
457
-	        require_once($this->Module()->getBaseDir() .'/bin/trap_class.php');
458
-	        $icingaweb2Etc=$this->Config()->get('config', 'icingaweb2_etc');
459
-	        $trap = new Trap($icingaweb2Etc);
460
-	        // load all plugins in case tested function is not enabled.
461
-	        $trap->pluginClass->registerAllPlugins(false);
462
-	        // Clean all spaces
463
-	        $functionString = $trap->ruleClass->eval_cleanup($functionString);
464
-	        // Eval functions
465
-	        $result = $trap->pluginClass->evaluateFunctionString($functionString);	        
466
-	    }
467
-	    catch (Exception $e)
468
-	    {
469
-	        $this->_helper->json(array('status'=>'Action error : '.$e->getMessage() ));
470
-	        return;
471
-	    }
454
+		// Only one action possible for now, no tests on action.
455
+		try
456
+		{
457
+			require_once($this->Module()->getBaseDir() .'/bin/trap_class.php');
458
+			$icingaweb2Etc=$this->Config()->get('config', 'icingaweb2_etc');
459
+			$trap = new Trap($icingaweb2Etc);
460
+			// load all plugins in case tested function is not enabled.
461
+			$trap->pluginClass->registerAllPlugins(false);
462
+			// Clean all spaces
463
+			$functionString = $trap->ruleClass->eval_cleanup($functionString);
464
+			// Eval functions
465
+			$result = $trap->pluginClass->evaluateFunctionString($functionString);	        
466
+		}
467
+		catch (Exception $e)
468
+		{
469
+			$this->_helper->json(array('status'=>'Action error : '.$e->getMessage() ));
470
+			return;
471
+		}
472 472
 	    
473
-        $result = ($result === true)?'True':'False';
474
-        $this->_helper->json(array('status'=>'OK','message' => $result));
473
+		$result = ($result === true)?'True':'False';
474
+		$this->_helper->json(array('status'=>'OK','message' => $result));
475 475
 	}
476 476
 
477
-    /**************   Utilities **********************/
477
+	/**************   Utilities **********************/
478 478
 
479 479
 	private function checkPostVar(array $postData,string $postVar, string $validRegexp) : string
480 480
 	{
481
-	    if (!isset ($postData[$postVar]))
482
-	    {
483
-	        $this->_helper->json(array('status'=>'No ' . $postVar));
484
-	        return '';
485
-	    }
486
-	    if (preg_match('/'.$validRegexp.'/', $postData[$postVar]) != 1)
487
-	    {
488
-	        $this->_helper->json(array('status'=>'Unknown ' . $postVar . ' value '.$postData[$postVar]));
489
-	        return '';
490
-	    }
491
-	    return $postData[$postVar];
481
+		if (!isset ($postData[$postVar]))
482
+		{
483
+			$this->_helper->json(array('status'=>'No ' . $postVar));
484
+			return '';
485
+		}
486
+		if (preg_match('/'.$validRegexp.'/', $postData[$postVar]) != 1)
487
+		{
488
+			$this->_helper->json(array('status'=>'Unknown ' . $postVar . ' value '.$postData[$postVar]));
489
+			return '';
490
+		}
491
+		return $postData[$postVar];
492 492
 	}
493 493
 }
Please login to merge, or discard this patch.