@@ -24,7 +24,9 @@ discard block |
||
| 24 | 24 | $this->prepareTabs()->activate('status'); |
| 25 | 25 | |
| 26 | 26 | $dbConn = $this->getUIDatabase()->getDb(); |
| 27 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 27 | + if ($dbConn === null) { |
|
| 28 | + throw new \ErrorException('uncatched db error'); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | 31 | $this->getHandlerListTable()->setConnection($dbConn); |
| 30 | 32 | $this->getHandlerListTable()->setMibloader($this->getMIB()); |
@@ -52,8 +54,7 @@ discard block |
||
| 52 | 54 | if ($this->params->get('rule') !== null) |
| 53 | 55 | { |
| 54 | 56 | $this->view->rule= $this->params->get('rule'); |
| 55 | - } |
|
| 56 | - else |
|
| 57 | + } else |
|
| 57 | 58 | { |
| 58 | 59 | $this->view->rule=''; |
| 59 | 60 | } |
@@ -107,8 +108,7 @@ discard block |
||
| 107 | 108 | try |
| 108 | 109 | { |
| 109 | 110 | $hosts=$this->getUIDatabase()->getHostByIP($hostfilter); |
| 110 | - } |
|
| 111 | - catch (Exception $e) |
|
| 111 | + } catch (Exception $e) |
|
| 112 | 112 | { |
| 113 | 113 | $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage()); |
| 114 | 114 | } |
@@ -121,8 +121,7 @@ discard block |
||
| 121 | 121 | // Tell JS to get services when page is loaded |
| 122 | 122 | $this->view->serviceGet=true; |
| 123 | 123 | |
| 124 | - } |
|
| 125 | - else |
|
| 124 | + } else |
|
| 126 | 125 | { |
| 127 | 126 | foreach($hosts as $key=>$val) |
| 128 | 127 | { |
@@ -172,11 +171,14 @@ discard block |
||
| 172 | 171 | $allObjects[$val->oid]=null; |
| 173 | 172 | } |
| 174 | 173 | } |
| 175 | - if ($allObjects!=null) // in case trap doesn't have objects or is not resolved |
|
| 174 | + if ($allObjects!=null) { |
|
| 175 | + // in case trap doesn't have objects or is not resolved |
|
| 176 | 176 | { |
| 177 | 177 | foreach ($allObjects as $key => $val) |
| 178 | 178 | { |
| 179 | - if ($val==null) { continue; } |
|
| 179 | + if ($val==null) { continue; |
|
| 180 | + } |
|
| 181 | + } |
|
| 180 | 182 | array_push($this->view->objectList, array( |
| 181 | 183 | $oid_index, |
| 182 | 184 | $key, |
@@ -208,8 +210,7 @@ discard block |
||
| 208 | 210 | { |
| 209 | 211 | $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore'; |
| 210 | 212 | $this->view->serviceGet=false; |
| 211 | - } |
|
| 212 | - else |
|
| 213 | + } else |
|
| 213 | 214 | { |
| 214 | 215 | // Tell JS to get services when page is loaded |
| 215 | 216 | $this->view->serviceGet=true; |
@@ -218,8 +219,7 @@ discard block |
||
| 218 | 219 | if (count($serviceID) ==0) |
| 219 | 220 | { |
| 220 | 221 | $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
| 221 | - } |
|
| 222 | - else |
|
| 222 | + } else |
|
| 223 | 223 | { |
| 224 | 224 | $this->view->serviceSet=$serviceID[0]->id; |
| 225 | 225 | } |
@@ -238,8 +238,7 @@ discard block |
||
| 238 | 238 | { |
| 239 | 239 | $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore'; |
| 240 | 240 | $this->view->serviceGroupGet=false; |
| 241 | - } |
|
| 242 | - else |
|
| 241 | + } else |
|
| 243 | 242 | { |
| 244 | 243 | $grpServices=$this->getUIDatabase()->getServicesByHostGroupid($group_get[0]->id); |
| 245 | 244 | $foundGrpService=0; |
@@ -291,8 +290,7 @@ discard block |
||
| 291 | 290 | $object['type'], |
| 292 | 291 | $object['type_enum'] |
| 293 | 292 | )); |
| 294 | - } |
|
| 295 | - else |
|
| 293 | + } else |
|
| 296 | 294 | { |
| 297 | 295 | array_push($curObjectList, array( |
| 298 | 296 | $index, |
@@ -363,8 +361,7 @@ discard block |
||
| 363 | 361 | $this->view->selectGroup=false; |
| 364 | 362 | // Check if hostname still exists |
| 365 | 363 | $this->add_check_host_exists($ruleDetail); |
| 366 | - } |
|
| 367 | - else |
|
| 364 | + } else |
|
| 368 | 365 | { |
| 369 | 366 | $this->view->selectGroup=true; |
| 370 | 367 | $this->add_check_hostgroup_exists($ruleDetail); // Check if groupe exists |
@@ -372,9 +369,11 @@ discard block |
||
| 372 | 369 | |
| 373 | 370 | $this->view->mainoid=$ruleDetail->trap_oid; |
| 374 | 371 | $oidName=$this->getMIB()->translateOID($ruleDetail->trap_oid); |
| 375 | - if ($oidName != null) // oid is found in mibs |
|
| 372 | + if ($oidName != null) { |
|
| 373 | + // oid is found in mibs |
|
| 376 | 374 | { |
| 377 | - $this->view->mib=$oidName['mib']; |
|
| 375 | + $this->view->mib=$oidName['mib']; |
|
| 376 | + } |
|
| 378 | 377 | $this->view->name=$oidName['name']; |
| 379 | 378 | $this->view->trapListForMIB=$this->getMIB() |
| 380 | 379 | ->getTrapList($oidName['mib']); |
@@ -429,8 +428,7 @@ discard block |
||
| 429 | 428 | try |
| 430 | 429 | { |
| 431 | 430 | $this->getUIDatabase()->deleteRule($postData[$params['db_rule']['post']]); |
| 432 | - } |
|
| 433 | - catch (Exception $e) |
|
| 431 | + } catch (Exception $e) |
|
| 434 | 432 | { |
| 435 | 433 | $this->_helper->json(array('status'=>$e->getMessage())); |
| 436 | 434 | return; |
@@ -444,13 +442,15 @@ discard block |
||
| 444 | 442 | } |
| 445 | 443 | foreach (array_keys($params) as $key) |
| 446 | 444 | { |
| 447 | - if ($params[$key]['post']==null) continue; // data not sent in post vars |
|
| 445 | + if ($params[$key]['post']==null) { |
|
| 446 | + continue; |
|
| 447 | + } |
|
| 448 | + // data not sent in post vars |
|
| 448 | 449 | if (! isset($postData[$params[$key]['post']])) |
| 449 | 450 | { |
| 450 | 451 | // should not happen as the js checks data |
| 451 | 452 | $this->_helper->json(array('status'=>'No ' . $key)); |
| 452 | - } |
|
| 453 | - else |
|
| 453 | + } else |
|
| 454 | 454 | { |
| 455 | 455 | $data=$postData[$params[$key]['post']]; |
| 456 | 456 | if ($data!=null && $data !="") |
@@ -485,8 +485,7 @@ discard block |
||
| 485 | 485 | $this->_helper->json(array('status'=>"Invalid service id : Please re enter service")); |
| 486 | 486 | return; |
| 487 | 487 | } |
| 488 | - } |
|
| 489 | - else |
|
| 488 | + } else |
|
| 490 | 489 | { |
| 491 | 490 | $object=$this->getUIDatabase()->getObjectNameByid($params['hostid']['val']); |
| 492 | 491 | if ($params['host_name']['val'] != $object->name1) |
@@ -510,14 +509,12 @@ discard block |
||
| 510 | 509 | if ($params['db_rule']['val'] == -1 ) |
| 511 | 510 | { |
| 512 | 511 | $ruleID=$this->getUIDatabase()->addHandlerRule($dbparams); |
| 513 | - } |
|
| 514 | - else |
|
| 512 | + } else |
|
| 515 | 513 | { |
| 516 | 514 | $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']); |
| 517 | 515 | $ruleID=$params['db_rule']['val']; |
| 518 | 516 | } |
| 519 | - } |
|
| 520 | - catch (Exception $e) |
|
| 517 | + } catch (Exception $e) |
|
| 521 | 518 | { |
| 522 | 519 | $this->_helper->json(array('status'=>$e->getMessage())); |
| 523 | 520 | return; |
@@ -536,7 +533,9 @@ discard block |
||
| 536 | 533 | $queryArray=$this->getModuleConfig()->trapDetailQuery(); |
| 537 | 534 | |
| 538 | 535 | $dbConn = $this->getUIDatabase()->getDbConn(); |
| 539 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 536 | + if ($dbConn === null) { |
|
| 537 | + throw new \ErrorException('uncatched db error'); |
|
| 538 | + } |
|
| 540 | 539 | // *************** Get main data |
| 541 | 540 | // extract columns and titles; |
| 542 | 541 | $elmts=NULL; |
@@ -554,8 +553,7 @@ discard block |
||
| 554 | 553 | $trapDetail = 'NULL'; |
| 555 | 554 | throw new Exception('No traps was found with id = '.$trapid); |
| 556 | 555 | } |
| 557 | - } |
|
| 558 | - catch (Exception $e) |
|
| 556 | + } catch (Exception $e) |
|
| 559 | 557 | { |
| 560 | 558 | $this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail,true),$e->getMessage()); |
| 561 | 559 | return; |
@@ -575,7 +573,9 @@ discard block |
||
| 575 | 573 | $queryArrayData=$this->getModuleConfig()->trapDataDetailQuery(); |
| 576 | 574 | |
| 577 | 575 | $dbConn = $this->getUIDatabase()->getDbConn(); |
| 578 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 576 | + if ($dbConn === null) { |
|
| 577 | + throw new \ErrorException('uncatched db error'); |
|
| 578 | + } |
|
| 579 | 579 | // *************** Get object data |
| 580 | 580 | // extract columns and titles; |
| 581 | 581 | $data_elmts=NULL; |
@@ -589,8 +589,7 @@ discard block |
||
| 589 | 589 | ->where('trap_id=?',$trapid); |
| 590 | 590 | $trapDetail=$dbConn->fetchAll($query); |
| 591 | 591 | // if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid); |
| 592 | - } |
|
| 593 | - catch (Exception $e) |
|
| 592 | + } catch (Exception $e) |
|
| 594 | 593 | { |
| 595 | 594 | $this->displayExitError('Add handler : get trap data detail : ',$e->getMessage()); |
| 596 | 595 | return array(); |
@@ -610,7 +609,9 @@ discard block |
||
| 610 | 609 | $queryArray=$this->getModuleConfig()->ruleDetailQuery(); |
| 611 | 610 | |
| 612 | 611 | $dbConn = $this->getUIDatabase()->getDbConn(); |
| 613 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 612 | + if ($dbConn === null) { |
|
| 613 | + throw new \ErrorException('uncatched db error'); |
|
| 614 | + } |
|
| 614 | 615 | // *************** Get main data |
| 615 | 616 | try |
| 616 | 617 | { |
@@ -618,9 +619,10 @@ discard block |
||
| 618 | 619 | ->from($this->getModuleConfig()->getTrapRuleName(),$queryArray) |
| 619 | 620 | ->where('id=?',$ruleid); |
| 620 | 621 | $ruleDetail=$dbConn->fetchRow($query); |
| 621 | - if ( $ruleDetail == null ) throw new Exception('No rule was found with id = '.$ruleid); |
|
| 622 | - } |
|
| 623 | - catch (Exception $e) |
|
| 622 | + if ( $ruleDetail == null ) { |
|
| 623 | + throw new Exception('No rule was found with id = '.$ruleid); |
|
| 624 | + } |
|
| 625 | + } catch (Exception $e) |
|
| 624 | 626 | { |
| 625 | 627 | $this->displayExitError('Update handler : get rule detail',$e->getMessage()); |
| 626 | 628 | throw new Exception('Error : ' . $e->getMessage()); |
@@ -23,8 +23,9 @@ discard block |
||
| 23 | 23 | exit(1); |
| 24 | 24 | } |
| 25 | 25 | $rule=chop(fgets($inputStream)); |
| 26 | -} else |
|
| 26 | +} else { |
|
| 27 | 27 | $rule=$options['r']; |
| 28 | +} |
|
| 28 | 29 | |
| 29 | 30 | try |
| 30 | 31 | { |
@@ -34,7 +35,6 @@ discard block |
||
| 34 | 35 | $val = $trap->ruleClass->evaluation($rule,$item); |
| 35 | 36 | if ($val==true) { printf( "true"); } else { printf( "false");} |
| 36 | 37 | printf("\n"); |
| 37 | -} |
|
| 38 | -catch (Exception $e) { printf("%s\n",$e->getMessage()); exit(1);} |
|
| 38 | +} catch (Exception $e) { printf("%s\n",$e->getMessage()); exit(1);} |
|
| 39 | 39 | |
| 40 | 40 | exit(0); |