Passed
Push — master ( b8f383...dcdb45 )
by Patrick
02:09
created
application/clicommands/StatusCommand.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@
 block discarded – undo
40 40
 			$query = $dataBase->select()->from($Config->getTrapRuleName(),array('COUNT(*)'));			
41 41
 			printf("Number of rules : %s\n", $dataBase->fetchOne($query) );
42 42
 			
43
-		}
44
-		catch (Exception $e)
43
+		} catch (Exception $e)
45 44
 		{
46 45
 			printf('Error in DB : %s\n', $e->getMessage());
47 46
 		}	   
Please login to merge, or discard this patch.
application/clicommands/TrapsCommand.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,14 +42,12 @@  discard block
 block discarded – undo
42 42
 			if ($days=='<default>')
43 43
 			{
44 44
 				$trap->eraseOldTraps();
45
-			}
46
-			else
45
+			} else
47 46
 			{
48 47
 				$trap->eraseOldTraps($days);
49 48
 			}
50 49
 			
51
-		}
52
-		catch (Exception $e)
50
+		} catch (Exception $e)
53 51
 		{
54 52
 			echo 'Error in updating : ' . $e->getMessage();
55 53
 		}	   
@@ -74,8 +72,7 @@  discard block
 block discarded – undo
74 72
 		try 
75 73
 		{
76 74
 			$trap->reset_services();
77
-		} 
78
-		catch (Exception $e) 
75
+		} catch (Exception $e) 
79 76
 		{
80 77
 			echo 'ERROR : '. $e->getMessage();
81 78
 		}
Please login to merge, or discard this patch.
application/clicommands/MibCommand.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -62,8 +62,7 @@  discard block
 block discarded – undo
62 62
 		if ($pid == 1)
63 63
 		{
64 64
 		    $trap->setLogging($logLevel,'display');
65
-		}
66
-		else
65
+		} else
67 66
 		{  // use default display TODO : if default is 'display' son process will be killed at first output....
68 67
 		    if ($pid != 0)
69 68
 		    {
@@ -72,8 +71,7 @@  discard block
 block discarded – undo
72 71
 		        fclose($file);
73 72
 		        echo "OK : process $pid in bckground";
74 73
 		        return 0;
75
-		    }
76
-		    else
74
+		    } else
77 75
 		    {  // son process : close all file descriptors and go to a new session
78 76
 		        fclose($file);		        
79 77
 // 		        $sid = posix_setsid();
@@ -83,8 +81,7 @@  discard block
 block discarded – undo
83 81
                 try
84 82
                 {
85 83
                     $trap->update_mib_database(false,$forceCheck);
86
-                }
87
-                catch (Exception $e)
84
+                } catch (Exception $e)
88 85
                 {
89 86
                     $trap->trapLog('Error in updating : ' . $e->getMessage(),2);
90 87
                 }
@@ -101,8 +98,7 @@  discard block
 block discarded – undo
101 98
 			$trap->update_mib_database(true,$forceCheck);
102 99
 			echo "Done\n";
103 100
 			
104
-		}
105
-		catch (Exception $e)
101
+		} catch (Exception $e)
106 102
 		{
107 103
 			echo 'Error in updating : ' . $e->getMessage();
108 104
 		}
@@ -144,8 +140,7 @@  discard block
 block discarded – undo
144 140
 			$query = $db->select()->from($Config->getTrapRuleName(),array('COUNT(*)'));			
145 141
 			echo "Number of rules : " . $db->fetchOne($query) ."\n";		
146 142
 			
147
-		}
148
-		catch (Exception $e)
143
+		} catch (Exception $e)
149 144
 		{
150 145
 			echo 'Error in DB : ' . $e->getMessage();
151 146
 		}	   
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapTableHostList.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -256,7 +256,9 @@  discard block
 block discarded – undo
256 256
 			$first=1;
257 257
 			foreach($this->moduleConfig->getTrapListSearchColumns() as $column)
258 258
 			{
259
-				if ($first==0) $sql.=' OR ';
259
+				if ($first==0) {
260
+					$sql.=' OR ';
261
+				}
260 262
 				$first=0;
261 263
 				$sql.=" ".$column." LIKE  '%".$this->filter_query."%' ";
262 264
 			}
@@ -264,10 +266,14 @@  discard block
 block discarded – undo
264 266
 		}
265 267
 		if ($this->filter_done == 1)
266 268
 		{
267
-			if ($sql != '') $sql.=' AND ';
269
+			if ($sql != '') {
270
+				$sql.=' AND ';
271
+			}
268 272
 			$sql.="(status != 'done')";
269 273
 		}
270
-		if ($sql != '') $query->where($sql);		
274
+		if ($sql != '') {
275
+			$query->where($sql);
276
+		}
271 277
         return $query;
272 278
     }	
273 279
 
Please login to merge, or discard this patch.
library/Trapdirector/Tables/HandlerTableList.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -99,13 +99,11 @@  discard block
 block discarded – undo
99 99
 								if (isset($oidName['name']))
100 100
 								{
101 101
 									$val=$oidName['name'];
102
-								}
103
-								else
102
+								} else
104 103
 								{
105 104
 									$val = $row->$rowkey;
106 105
 								}								
107
-							}
108
-							else
106
+							} else
109 107
 							{
110 108
 								$val = $row->$rowkey;
111 109
 							}
@@ -114,8 +112,7 @@  discard block
 block discarded – undo
114 112
 							if ($row->$rowkey == null)
115 113
 							{
116 114
 								$val = $row->host_group_name;
117
-							}
118
-							else
115
+							} else
119 116
 							{
120 117
 								$val = $row->$rowkey;
121 118
 							}
Please login to merge, or discard this patch.
library/Trapdirector/Tables/TrapTableList.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -214,7 +214,9 @@  discard block
 block discarded – undo
214 214
 			$first=1;
215 215
 			foreach($this->moduleConfig->getTrapListSearchColumns() as $column)
216 216
 			{
217
-				if ($first==0) $sql.=' OR ';
217
+				if ($first==0) {
218
+					$sql.=' OR ';
219
+				}
218 220
 				$first=0;
219 221
 				$sql.=" CAST(".$column." AS  char(100))  LIKE  '%".$this->filter_query."%' ";
220 222
 			}
@@ -222,10 +224,14 @@  discard block
 block discarded – undo
222 224
 		}
223 225
 		if ($this->filter_done == 1)
224 226
 		{
225
-			if ($sql != '') $sql.=' AND ';
227
+			if ($sql != '') {
228
+				$sql.=' AND ';
229
+			}
226 230
 			$sql.="(status != 'done')";
227 231
 		}
228
-		if ($sql != '') $query->where($sql);		
232
+		if ($sql != '') {
233
+			$query->where($sql);
234
+		}
229 235
         return $query;
230 236
     }	
231 237
 
Please login to merge, or discard this patch.
library/Trapdirector/Icinga2Api.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -164,8 +164,7 @@  discard block
 block discarded – undo
164 164
             if (property_exists($result,'status'))
165 165
             {
166 166
                 $message=$result->status;
167
-            }
168
-            else 
167
+            } else 
169 168
             {
170 169
                 $message="Unkown status";
171 170
             }
@@ -176,8 +175,7 @@  discard block
 block discarded – undo
176 175
             if (isset($result->results[0]))
177 176
             {
178 177
                 return array(true,'code '.$result->results[0]->code.' : '.$result->results[0]->status);
179
-            }
180
-            else
178
+            } else
181 179
             {
182 180
                 return array(false,'Service not found');
183 181
             }
@@ -219,8 +217,7 @@  discard block
 block discarded – undo
219 217
             if (property_exists($result,'status'))
220 218
             {
221 219
                 throw new Exception('Ret code ' .$result->error.' : ' . $result->status);
222
-            }
223
-            else
220
+            } else
224 221
             {
225 222
                 throw new Exception('Ret code ' .$result->error.' : Unkown status');
226 223
             }
@@ -265,8 +262,7 @@  discard block
 block discarded – undo
265 262
             if (property_exists($result,'status'))
266 263
             {
267 264
                 throw new Exception('Ret code ' .$result->error.' : ' . $result->status);
268
-            }
269
-            else
265
+            } else
270 266
             {
271 267
                 throw new Exception('Ret code ' .$result->error.' : Unkown status');
272 268
             }
Please login to merge, or discard this patch.
tests/expr_test.php 1 patch
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
 if (! $input) {
18 18
   $inputStream=fopen('php://stdin', 'r');
19 19
   $rule=chop(fgets($inputStream));
20
-} else
20
+} else {
21 21
   $rule=$options['r'];
22
+}
22 23
 
23 24
 try
24 25
 {
@@ -28,8 +29,7 @@  discard block
 block discarded – undo
28 29
   $val = $trap->evaluation($rule,$item);
29 30
   if ($val==true) { printf( "true"); } else { printf( "false");}
30 31
   printf("\n");
31
-}
32
-catch (Exception $e) { printf("%s\n",$e->getMessage()); exit(1);}
32
+} catch (Exception $e) { printf("%s\n",$e->getMessage()); exit(1);}
33 33
 
34 34
 exit(0);
35 35
 ?>
Please login to merge, or discard this patch.
application/controllers/HandlerController.php 1 patch
Braces   +35 added lines, -39 removed lines patch added patch discarded remove patch
@@ -51,8 +51,7 @@  discard block
 block discarded – undo
51 51
 	    if ($this->params->get('rule') !== null) 
52 52
 	    {
53 53
 	        $this->view->rule= $this->params->get('rule');
54
-	    }
55
-	    else
54
+	    } else
56 55
 	    {
57 56
 	        $this->view->rule='';
58 57
 	    }
@@ -113,8 +112,7 @@  discard block
 block discarded – undo
113 112
 			try
114 113
 			{
115 114
 				$hosts=$this->getHostByIP($hostfilter);
116
-			}
117
-			catch (Exception $e)
115
+			} catch (Exception $e)
118 116
 			{
119 117
 				$this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage());
120 118
 			}
@@ -127,8 +125,7 @@  discard block
 block discarded – undo
127 125
 				// Tell JS to get services when page is loaded
128 126
 				$this->view->serviceGet=true;
129 127
 				
130
-			}
131
-			else
128
+			} else
132 129
 			{
133 130
 				foreach($hosts as $key=>$val)
134 131
 				{
@@ -178,11 +175,14 @@  discard block
 block discarded – undo
178 175
 					$allObjects[$val->oid]=null;
179 176
 				}
180 177
 			}
181
-			if ($allObjects!=null) // in case trap doesn't have objects or is not resolved
178
+			if ($allObjects!=null) {
179
+				// in case trap doesn't have objects or is not resolved
182 180
 			{
183 181
 				foreach ($allObjects as $key => $val)
184 182
 				{
185
-					if ($val==null) { continue; }
183
+					if ($val==null) { continue;
184
+			}
185
+			}
186 186
 					array_push($this->view->objectList, array(
187 187
 					    $oid_index,
188 188
 						$key,
@@ -231,8 +231,7 @@  discard block
 block discarded – undo
231 231
 			    {
232 232
 			        $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore';
233 233
 			        $this->view->serviceGet=false;
234
-			    }
235
-			    else
234
+			    } else
236 235
 			    {
237 236
     				// Tell JS to get services when page is loaded
238 237
     				$this->view->serviceGet=true;
@@ -241,14 +240,12 @@  discard block
 block discarded – undo
241 240
     				if (count($serviceID) ==0)
242 241
     				{
243 242
     				    $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore';
244
-    				} 
245
-    				else
243
+    				} else
246 244
     				{
247 245
     				    $this->view->serviceSet=$serviceID[0]->id;
248 246
     				}
249 247
 			    }
250
-			}
251
-			else
248
+			} else
252 249
 			{
253 250
 			    $this->view->selectGroup=true;
254 251
 			    // Check if groupe exists
@@ -257,8 +254,7 @@  discard block
 block discarded – undo
257 254
 			    {
258 255
 			        $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore';
259 256
 			        $this->view->serviceGroupGet=false;
260
-			    }
261
-			    else
257
+			    } else
262 258
 			    {
263 259
 			        $grpServices=$this->getServicesByHostGroupid($group_get[0]->id);
264 260
 			        $foundGrpService=0;
@@ -281,9 +277,11 @@  discard block
 block discarded – undo
281 277
 			}
282 278
 			$this->view->mainoid=$ruleDetail->trap_oid;
283 279
 			$oidName=$this->getMIB()->translateOID($ruleDetail->trap_oid);
284
-			if ($oidName != null)  // oid is found in mibs
280
+			if ($oidName != null) {
281
+				// oid is found in mibs
285 282
 			{
286
-				$this->view->mib=$oidName['mib']; 
283
+				$this->view->mib=$oidName['mib'];
284
+			}
287 285
 				$this->view->name=$oidName['name'];
288 286
 				$this->view->trapListForMIB=$this->getMIB()
289 287
 					->getTrapList($oidName['mib']);				
@@ -310,8 +308,7 @@  discard block
 block discarded – undo
310 308
 						$object['type'],
311 309
 						$object['type_enum']
312 310
 					));
313
-				}
314
-				else
311
+				} else
315 312
 				{
316 313
 					array_push($curObjectList, array(
317 314
 					    $index,
@@ -369,8 +366,7 @@  discard block
 block discarded – undo
369 366
 			try
370 367
 			{
371 368
 				$this->deleteRule($postData[$params['db_rule']['post']]);
372
-			}
373
-			catch (Exception $e)
369
+			} catch (Exception $e)
374 370
 			{
375 371
 				$this->_helper->json(array('status'=>$e->getMessage()));
376 372
 				return;
@@ -384,13 +380,15 @@  discard block
 block discarded – undo
384 380
 		}		
385 381
 		foreach (array_keys($params) as $key)
386 382
 		{
387
-			if ($params[$key]['post']==null) continue; // data not sent in post vars
383
+			if ($params[$key]['post']==null) {
384
+				continue;
385
+			}
386
+			// data not sent in post vars
388 387
 			if (! isset($postData[$params[$key]['post']]))
389 388
 			{
390 389
 				// should not happen as the js checks data
391 390
 				$this->_helper->json(array('status'=>'No ' . $key));
392
-			}
393
-			else
391
+			} else
394 392
 			{
395 393
 				$data=$postData[$params[$key]['post']];
396 394
 				if ($data!=null && $data !="")
@@ -420,8 +418,7 @@  discard block
 block discarded – undo
420 418
 					$this->_helper->json(array('status'=>"Invalid service id : Please re enter service"));
421 419
 					return;
422 420
 				}
423
-			}
424
-			else
421
+			} else
425 422
 			{
426 423
 				$object=$this->getObjectNameByid($params['hostid']['val']);
427 424
 				if ($params['host_name']['val'] != $object->name1)
@@ -445,14 +442,12 @@  discard block
 block discarded – undo
445 442
 			if ($params['db_rule']['val'] == -1 ) 
446 443
 			{
447 444
 				$ruleID=$this->addHandlerRule($dbparams);
448
-			}
449
-			else
445
+			} else
450 446
 			{
451 447
 				$this->updateHandlerRule($dbparams,$params['db_rule']['val']);
452 448
 				$ruleID=$params['db_rule']['val'];
453 449
 			}
454
-		}
455
-		catch (Exception $e)
450
+		} catch (Exception $e)
456 451
 		{
457 452
 			$this->_helper->json(array('status'=>$e->getMessage()));
458 453
 			return;
@@ -483,9 +478,10 @@  discard block
 block discarded – undo
483 478
 				->from($this->getModuleConfig()->getTrapTableName(),$elmts)
484 479
 				->where('id=?',$trapid);
485 480
 			$trapDetail=$db->fetchRow($query);
486
-			if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid);
487
-		}
488
-		catch (Exception $e)
481
+			if ( $trapDetail == null ) {
482
+				throw new Exception('No traps was found with id = '.$trapid);
483
+			}
484
+		} catch (Exception $e)
489 485
 		{
490 486
 			$this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail,true),$e->getMessage());
491 487
 			return;
@@ -518,8 +514,7 @@  discard block
 block discarded – undo
518 514
 				->where('trap_id=?',$trapid);
519 515
 			$trapDetail=$db->fetchAll($query);
520 516
 			// if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid);
521
-		}
522
-		catch (Exception $e)
517
+		} catch (Exception $e)
523 518
 		{
524 519
 			$this->displayExitError('Add handler : get trap data detail : ',$e->getMessage());
525 520
 			return array();
@@ -545,9 +540,10 @@  discard block
 block discarded – undo
545 540
 				->from($this->getModuleConfig()->getTrapRuleName(),$queryArray)
546 541
 				->where('id=?',$ruleid);
547 542
 			$ruleDetail=$db->fetchRow($query);
548
-			if ( $ruleDetail == null ) throw new Exception('No rule was found with id = '.$ruleid);
549
-		}
550
-		catch (Exception $e)
543
+			if ( $ruleDetail == null ) {
544
+				throw new Exception('No rule was found with id = '.$ruleid);
545
+			}
546
+		} catch (Exception $e)
551 547
 		{
552 548
 			$this->displayExitError('Update handler : get rule detail',$e->getMessage());
553 549
 			return array();
Please login to merge, or discard this patch.