Passed
Push — master ( 6af608...f4805a )
by Patrick
03:21
created
application/controllers/StatusController.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -22,18 +22,18 @@  discard block
 block discarded – undo
22 22
 		/************  Trapdb ***********/
23 23
 		try
24 24
 		{
25
-			$db = $this->getDb()->getConnection();
26
-			$query = $db->select()->from(
25
+			$db=$this->getDb()->getConnection();
26
+			$query=$db->select()->from(
27 27
 				$this->getModuleConfig()->getTrapTableName(),
28 28
 				array('COUNT(*)')
29 29
 			);			
30 30
 			$this->view->trap_count=$db->fetchOne($query);
31
-			$query = $db->select()->from(
31
+			$query=$db->select()->from(
32 32
 				$this->getModuleConfig()->getTrapDataTableName(),
33 33
 				array('COUNT(*)')
34 34
 			);			
35 35
 			$this->view->trap_object_count=$db->fetchOne($query);
36
-			$query = $db->select()->from(
36
+			$query=$db->select()->from(
37 37
 				$this->getModuleConfig()->getTrapRuleName(),
38 38
 				array('COUNT(*)')
39 39
 			);			
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 		}
45 45
 		catch (Exception $e)
46 46
 		{
47
-			$this->displayExitError('status',$e->getMessage());
47
+			$this->displayExitError('status', $e->getMessage());
48 48
 		}
49 49
 		
50 50
 		/*************** Log destination *******************/
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		}
60 60
 		catch (Exception $e)
61 61
 		{
62
-			$this->displayExitError('status',$e->getMessage());
62
+			$this->displayExitError('status', $e->getMessage());
63 63
 		}		
64 64
 		
65 65
 	} 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 				if ($action == 'update_mib_db')
86 86
 				{ // Do the update in background
87 87
 					$return=exec('icingacli trapdirector mib update --pid /tmp/trapdirector_update.pid');
88
-					if (preg_match('/OK/',$return))
88
+					if (preg_match('/OK/', $return))
89 89
 					{
90 90
 					    $this->_helper->json(array('status'=>'OK'));
91 91
 					}
@@ -94,32 +94,32 @@  discard block
 block discarded – undo
94 94
 				}
95 95
 				if ($action == 'check_update')
96 96
 				{
97
-				    $file=@fopen('/tmp/trapdirector_update.pid','r');
97
+				    $file=@fopen('/tmp/trapdirector_update.pid', 'r');
98 98
 				    if ($file == false)
99 99
 				    {   // process is dead
100
-				        $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file'));
100
+				        $this->_helper->json(array('status'=>'tu quoque fili', 'err'=>'Cannot open file'));
101 101
 				        return;
102 102
 				    }
103 103
 				    $pid=fgets($file);
104 104
 				    $output=array();
105 105
 				    $retVal=0;
106
-					exec('ps '.$pid,$output,$retVal);
106
+					exec('ps '.$pid, $output, $retVal);
107 107
 					if ($retVal == 0)
108 108
 					{ // process is alive
109 109
 						$this->_helper->json(array('status'=>'Alive and kicking'));
110 110
 					}
111 111
 					else
112 112
 					{ // process is dead
113
-					    $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid));
113
+					    $this->_helper->json(array('status'=>'tu quoque fili', 'err'=>'no proc'.$pid));
114 114
 					}
115 115
 				}
116
-				$this->_helper->json(array('status'=>'ERR : no '.$action.' action possible' ));
116
+				$this->_helper->json(array('status'=>'ERR : no '.$action.' action possible'));
117 117
 			}
118 118
 			/** Check for mib file UPLOAD */
119 119
 			if (isset($_FILES['mibfile']))
120 120
 			{
121 121
 				$name=$_FILES['mibfile']['name'];
122
-				$DirConf=explode(':',$this->Config()->get('config', 'snmptranslate_dirs'));
122
+				$DirConf=explode(':', $this->Config()->get('config', 'snmptranslate_dirs'));
123 123
 				$destDir=array_shift($DirConf);
124 124
 				if (!is_dir($destDir))
125 125
 				{
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 				    }
134 134
 				    else
135 135
 				    {
136
-				        $destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name";
137
-    				    if (move_uploaded_file($_FILES['mibfile']['tmp_name'],$destination)===false)
136
+				        $destination=$destDir.'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name";
137
+    				    if (move_uploaded_file($_FILES['mibfile']['tmp_name'], $destination) === false)
138 138
     				    {
139 139
     				        $this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations";
140 140
     				    }
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
 		}
151 151
 		
152 152
 		// snmptranslate tests
153
-		$snmptranslate = $this->Config()->get('config', 'snmptranslate');
153
+		$snmptranslate=$this->Config()->get('config', 'snmptranslate');
154 154
 		$this->view->snmptranslate_bin=$snmptranslate;
155 155
 		$this->view->snmptranslate_state='warn';
156
-		if (is_executable ( $snmptranslate ))
156
+		if (is_executable($snmptranslate))
157 157
 		{
158
-			$translate=exec($snmptranslate . ' 1');
159
-			if (preg_match('/iso/',$translate))
158
+			$translate=exec($snmptranslate.' 1');
159
+			if (preg_match('/iso/', $translate))
160 160
 			{
161 161
 				$this->view->snmptranslate='works fine';
162 162
 				$this->view->snmptranslate_state='ok';
@@ -174,46 +174,46 @@  discard block
 block discarded – undo
174 174
 		// mib database
175 175
 		
176 176
 		$this->view->mibDbCount=$this->getMIB()->countObjects();
177
-		$this->view->mibDbCountTrap=$this->getMIB()->countObjects(null,21);
177
+		$this->view->mibDbCountTrap=$this->getMIB()->countObjects(null, 21);
178 178
 		
179 179
 		// mib dirs
180 180
 		$DirConf=$this->Config()->get('config', 'snmptranslate_dirs');
181
-		$dirArray=explode(':',$DirConf);
181
+		$dirArray=explode(':', $DirConf);
182 182
 
183 183
 		// Get base directories from net-snmp-config
184 184
 		$output=$matches=array();
185 185
 		$retVal=0;
186
-		$sysDirs=exec('net-snmp-config --default-mibdirs',$output,$retVal);
187
-		if ($retVal==0)
186
+		$sysDirs=exec('net-snmp-config --default-mibdirs', $output, $retVal);
187
+		if ($retVal == 0)
188 188
 		{
189
-			$dirArray=array_merge($dirArray,explode(':',$sysDirs));
189
+			$dirArray=array_merge($dirArray, explode(':', $sysDirs));
190 190
 		}
191 191
 		else
192 192
 		{
193
-			$translateOut=exec($this->Config()->get('config', 'snmptranslate') . ' -Dinit_mib .1.3 2>&1 | grep MIBDIRS');
194
-			if (preg_match('/MIBDIRS.*\'([^\']+)\'/',$translateOut,$matches))
193
+			$translateOut=exec($this->Config()->get('config', 'snmptranslate').' -Dinit_mib .1.3 2>&1 | grep MIBDIRS');
194
+			if (preg_match('/MIBDIRS.*\'([^\']+)\'/', $translateOut, $matches))
195 195
 			{
196
-				$dirArray=array_merge($dirArray,explode(':',$matches[1]));
196
+				$dirArray=array_merge($dirArray, explode(':', $matches[1]));
197 197
 			}
198 198
 			else
199 199
 			{
200
-				array_push($dirArray,'Install net-snmp-config to see system directories');
200
+				array_push($dirArray, 'Install net-snmp-config to see system directories');
201 201
 			}
202 202
 		}
203 203
 		
204 204
 		$this->view->dirArray=$dirArray;
205 205
 		
206 206
 		$output=null;
207
-		foreach (explode(':',$DirConf) as $mibdir)
207
+		foreach (explode(':', $DirConf) as $mibdir)
208 208
 		{
209
-			exec('ls '.$mibdir.' | grep -v traplist.txt',$output);
209
+			exec('ls '.$mibdir.' | grep -v traplist.txt', $output);
210 210
 		}
211 211
 		//$i=0;$listFiles='';while (isset($output[$i])) $listFiles.=$output[$i++];
212 212
 		//$this->view->fileList=explode(' ',$listFiles);
213 213
 		$this->view->fileList=$output;
214 214
 		
215 215
 		// Zend form 
216
-		$this->view->form= new UploadForm();
216
+		$this->view->form=new UploadForm();
217 217
 		//$this->view->form= new Form('upload-form');
218 218
 		
219 219
 		
@@ -237,18 +237,18 @@  discard block
 block discarded – undo
237 237
 		$this->view->templateForm_output='';
238 238
 		if (isset($postData['template_name']) && isset($postData['template_revert_time']))
239 239
 		{
240
-			$template_create = 'icingacli director service create --json \'{ "check_command": "dummy", ';
241
-			$template_create .= '"check_interval": "' .$postData['template_revert_time']. '", "check_timeout": "20", "disabled": false, "enable_active_checks": true, "enable_event_handler": true, "enable_notifications": true, "enable_passive_checks": true, "enable_perfdata": true, "max_check_attempts": "1", ';
242
-			$template_create .= '"object_name": "'.$postData['template_name'].'", "object_type": "template", "retry_interval": "'.$postData['template_revert_time'].'"}\'';
240
+			$template_create='icingacli director service create --json \'{ "check_command": "dummy", ';
241
+			$template_create.='"check_interval": "'.$postData['template_revert_time'].'", "check_timeout": "20", "disabled": false, "enable_active_checks": true, "enable_event_handler": true, "enable_notifications": true, "enable_passive_checks": true, "enable_perfdata": true, "max_check_attempts": "1", ';
242
+			$template_create.='"object_name": "'.$postData['template_name'].'", "object_type": "template", "retry_interval": "'.$postData['template_revert_time'].'"}\'';
243 243
 			$output=array();
244 244
 			$ret_code=0;
245
-			exec($template_create,$output,$ret_code);
245
+			exec($template_create, $output, $ret_code);
246 246
 			if ($ret_code != 0)
247 247
 			{
248
-				$this->displayExitError("Status -> Services","Error creating template : ".$output[0].'<br>Command was : '.$template_create);
248
+				$this->displayExitError("Status -> Services", "Error creating template : ".$output[0].'<br>Command was : '.$template_create);
249 249
 			}
250
-			exec('icingacli director config deploy',$output,$ret_code);
251
-			$this->view->templateForm_output='Template '.$postData['template_name']. ' created';
250
+			exec('icingacli director config deploy', $output, $ret_code);
251
+			$this->view->templateForm_output='Template '.$postData['template_name'].' created';
252 252
 		}
253 253
 		
254 254
 		// template creation form
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
 	{
262 262
 		return $this->getTabs()->add('status', array(
263 263
 			'label' => $this->translate('Status'),
264
-			'url'   => $this->getModuleConfig()->urlPath() . '/status')
264
+			'url'   => $this->getModuleConfig()->urlPath().'/status')
265 265
 		)->add('mib', array(
266 266
 			'label' => $this->translate('MIB Management'),
267
-			'url'   => $this->getModuleConfig()->urlPath() . '/status/mib')
267
+			'url'   => $this->getModuleConfig()->urlPath().'/status/mib')
268 268
 		)->add('services', array(
269 269
 			'label' => $this->translate('Services management'),
270
-			'url'   => $this->getModuleConfig()->urlPath() . '/status/services')
270
+			'url'   => $this->getModuleConfig()->urlPath().'/status/services')
271 271
 		);
272 272
 	} 
273 273
 }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 // TODO : see if useless 
276 276
 class UploadForm extends Form
277 277
 { 
278
-    public function __construct($options = null) 
278
+    public function __construct($options=null) 
279 279
     {
280 280
         parent::__construct($options);
281 281
         $this->addElements2();
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
     public function addElements2()
285 285
     {
286 286
         // File Input
287
-        $file = new File('mib-file');
287
+        $file=new File('mib-file');
288 288
         $file->setLabel('Mib upload');
289 289
              //->setAttrib('multiple', null);
290 290
         $this->addElement($file);
291
-		$button = new Submit("upload",array('ignore'=>false));
292
-		$this->addElement($button);//->setIgnore(false);
291
+		$button=new Submit("upload", array('ignore'=>false));
292
+		$this->addElement($button); //->setIgnore(false);
293 293
     }
294 294
 }
Please login to merge, or discard this patch.