@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | { |
| 19 | 19 | $postData=$this->getRequest()->getPost(); |
| 20 | 20 | |
| 21 | - $hostFilter = $this->checkPostVar($postData, 'hostFilter', '.*'); |
|
| 21 | + $hostFilter=$this->checkPostVar($postData, 'hostFilter', '.*'); |
|
| 22 | 22 | |
| 23 | - $retHosts=array('status'=>'OK','hosts' => array()); |
|
| 23 | + $retHosts=array('status'=>'OK', 'hosts' => array()); |
|
| 24 | 24 | |
| 25 | 25 | $hosts=$this->getHostByIP($hostFilter); |
| 26 | 26 | foreach ($hosts as $val) |
| 27 | 27 | { |
| 28 | - array_push($retHosts['hosts'],$val->name); |
|
| 28 | + array_push($retHosts['hosts'], $val->name); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $this->_helper->json($retHosts); |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $postData=$this->getRequest()->getPost(); |
| 40 | 40 | |
| 41 | - $hostFilter = $this->checkPostVar($postData, 'hostFilter', '.*'); |
|
| 41 | + $hostFilter=$this->checkPostVar($postData, 'hostFilter', '.*'); |
|
| 42 | 42 | |
| 43 | - $retHosts=array('status'=>'OK','hosts' => array()); |
|
| 43 | + $retHosts=array('status'=>'OK', 'hosts' => array()); |
|
| 44 | 44 | |
| 45 | 45 | $hosts=$this->getHostGroupByName($hostFilter); |
| 46 | 46 | foreach ($hosts as $val) |
| 47 | 47 | { |
| 48 | - array_push($retHosts['hosts'],$val->name); |
|
| 48 | + array_push($retHosts['hosts'], $val->name); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | $this->_helper->json($retHosts); |
@@ -68,31 +68,31 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | else |
| 70 | 70 | { |
| 71 | - $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
|
| 71 | + $this->_helper->json(array('status'=>'No Hosts', 'hostid' => -1)); |
|
| 72 | 72 | return; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | $hostArray=$this->getHostByName($host); |
| 76 | 76 | if (count($hostArray) > 1) |
| 77 | 77 | { |
| 78 | - $this->_helper->json(array('status'=>'More than one host matches','hostid' => -1)); |
|
| 78 | + $this->_helper->json(array('status'=>'More than one host matches', 'hostid' => -1)); |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | else if (count($hostArray) == 0) |
| 82 | 82 | { |
| 83 | - $this->_helper->json(array('status'=>'No host matches','hostid' => -1)); |
|
| 83 | + $this->_helper->json(array('status'=>'No host matches', 'hostid' => -1)); |
|
| 84 | 84 | return; |
| 85 | 85 | } |
| 86 | 86 | $services=$this->getServicesByHostid($hostArray[0]->id); |
| 87 | 87 | if (count($services) < 1) |
| 88 | 88 | { |
| 89 | - $this->_helper->json(array('status'=>'No services found for host','hostid' => $hostArray[0]->id)); |
|
| 89 | + $this->_helper->json(array('status'=>'No services found for host', 'hostid' => $hostArray[0]->id)); |
|
| 90 | 90 | return; |
| 91 | 91 | } |
| 92 | - $retServices=array('status'=>'OK','services' => array(),'hostid' => $hostArray[0]->id); |
|
| 92 | + $retServices=array('status'=>'OK', 'services' => array(), 'hostid' => $hostArray[0]->id); |
|
| 93 | 93 | foreach ($services as $val) |
| 94 | 94 | { |
| 95 | - array_push($retServices['services'],array($val->id , $val->name)); |
|
| 95 | + array_push($retServices['services'], array($val->id, $val->name)); |
|
| 96 | 96 | } |
| 97 | 97 | $this->_helper->json($retServices); |
| 98 | 98 | } |
@@ -107,26 +107,26 @@ discard block |
||
| 107 | 107 | { |
| 108 | 108 | $postData=$this->getRequest()->getPost(); |
| 109 | 109 | |
| 110 | - $host = $this->checkPostVar($postData, 'host', '.+'); |
|
| 110 | + $host=$this->checkPostVar($postData, 'host', '.+'); |
|
| 111 | 111 | |
| 112 | 112 | $hostArray=$this->getHostGroupByName($host); |
| 113 | 113 | if (count($hostArray) > 1) |
| 114 | 114 | { |
| 115 | - $this->_helper->json(array('status'=>'More than one hostgroup matches','hostid' => -1)); |
|
| 115 | + $this->_helper->json(array('status'=>'More than one hostgroup matches', 'hostid' => -1)); |
|
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | else if (count($hostArray) == 0) |
| 119 | 119 | { |
| 120 | - $this->_helper->json(array('status'=>'No hostgroup matches','hostid' => -1)); |
|
| 120 | + $this->_helper->json(array('status'=>'No hostgroup matches', 'hostid' => -1)); |
|
| 121 | 121 | return; |
| 122 | 122 | } |
| 123 | 123 | $services=$this->getServicesByHostGroupid($hostArray[0]->id); |
| 124 | 124 | if (count($services) < 1) |
| 125 | 125 | { |
| 126 | - $this->_helper->json(array('status'=>'No services found for hostgroup','hostid' => $hostArray[0]->id)); |
|
| 126 | + $this->_helper->json(array('status'=>'No services found for hostgroup', 'hostid' => $hostArray[0]->id)); |
|
| 127 | 127 | return; |
| 128 | 128 | } |
| 129 | - $retServices=array('status'=>'OK','services' => $services,'hostid' => $hostArray[0]->id); |
|
| 129 | + $retServices=array('status'=>'OK', 'services' => $services, 'hostid' => $hostArray[0]->id); |
|
| 130 | 130 | |
| 131 | 131 | $this->_helper->json($retServices); |
| 132 | 132 | } |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | $postData=$this->getRequest()->getPost(); |
| 142 | 142 | |
| 143 | - $mib = $this->checkPostVar($postData, 'mib', '.*'); |
|
| 143 | + $mib=$this->checkPostVar($postData, 'mib', '.*'); |
|
| 144 | 144 | |
| 145 | 145 | try |
| 146 | 146 | { |
| 147 | 147 | $traplist=$this->getMIB()->getTrapList($mib); |
| 148 | - $retTraps=array('status'=>'OK','traps' => $traplist); |
|
| 148 | + $retTraps=array('status'=>'OK', 'traps' => $traplist); |
|
| 149 | 149 | } |
| 150 | 150 | catch (Exception $e) |
| 151 | 151 | { |
@@ -163,12 +163,12 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | $postData=$this->getRequest()->getPost(); |
| 165 | 165 | |
| 166 | - $trap = $this->checkPostVar($postData, 'trap', '.*'); |
|
| 166 | + $trap=$this->checkPostVar($postData, 'trap', '.*'); |
|
| 167 | 167 | |
| 168 | 168 | try |
| 169 | 169 | { |
| 170 | 170 | $objectlist=$this->getMIB()->getObjectList($trap); |
| 171 | - $retObjects=array('status'=>'OK','objects' => $objectlist); |
|
| 171 | + $retObjects=array('status'=>'OK', 'objects' => $objectlist); |
|
| 172 | 172 | } |
| 173 | 173 | catch (Exception $e) |
| 174 | 174 | { |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | $postData=$this->getRequest()->getPost(); |
| 204 | 204 | |
| 205 | - $oid = $this->checkPostVar($postData, 'oid', '.*'); |
|
| 205 | + $oid=$this->checkPostVar($postData, 'oid', '.*'); |
|
| 206 | 206 | |
| 207 | 207 | // Try to get oid name from snmptranslate |
| 208 | 208 | if (($object=$this->getMIB()->translateOID($oid)) == null) |
@@ -235,19 +235,19 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | $postData=$this->getRequest()->getPost(); |
| 237 | 237 | |
| 238 | - $days = $this->checkPostVar($postData, 'days', '^[0-9]+$'); |
|
| 238 | + $days=$this->checkPostVar($postData, 'days', '^[0-9]+$'); |
|
| 239 | 239 | |
| 240 | - $action = $this->checkPostVar($postData, 'action', 'save|execute'); |
|
| 240 | + $action=$this->checkPostVar($postData, 'action', 'save|execute'); |
|
| 241 | 241 | |
| 242 | 242 | if ($action == 'save') |
| 243 | 243 | { |
| 244 | 244 | try |
| 245 | 245 | { |
| 246 | - $this->getUIDatabase()->setDBConfigValue('db_remove_days',$days); |
|
| 246 | + $this->getUIDatabase()->setDBConfigValue('db_remove_days', $days); |
|
| 247 | 247 | } |
| 248 | 248 | catch (Exception $e) |
| 249 | 249 | { |
| 250 | - $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
|
| 250 | + $this->_helper->json(array('status'=>'Save error : '.$e->getMessage())); |
|
| 251 | 251 | return; |
| 252 | 252 | } |
| 253 | 253 | $this->_helper->json(array('status'=>'OK')); |
@@ -257,16 +257,16 @@ discard block |
||
| 257 | 257 | { |
| 258 | 258 | try |
| 259 | 259 | { |
| 260 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 260 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 261 | 261 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 262 | 262 | $debug_level=4; |
| 263 | - $trap = new Trap($icingaweb2_etc); |
|
| 264 | - $trap->setLogging($debug_level,'syslog'); |
|
| 263 | + $trap=new Trap($icingaweb2_etc); |
|
| 264 | + $trap->setLogging($debug_level, 'syslog'); |
|
| 265 | 265 | $trap->eraseOldTraps($days); |
| 266 | 266 | } |
| 267 | 267 | catch (Exception $e) |
| 268 | 268 | { |
| 269 | - $this->_helper->json(array('status'=>'execute error : '.$e->getMessage() )); |
|
| 269 | + $this->_helper->json(array('status'=>'execute error : '.$e->getMessage())); |
|
| 270 | 270 | return; |
| 271 | 271 | } |
| 272 | 272 | $this->_helper->json(array('status'=>'OK')); |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | { |
| 285 | 285 | $postData=$this->getRequest()->getPost(); |
| 286 | 286 | |
| 287 | - $destination = $this->checkPostVar($postData, 'destination', '.*'); |
|
| 287 | + $destination=$this->checkPostVar($postData, 'destination', '.*'); |
|
| 288 | 288 | $logDest=$this->getModuleConfig()->getLogDestinations(); |
| 289 | 289 | if (!isset($logDest[$destination])) |
| 290 | 290 | { |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | if (isset($postData['file'])) |
| 296 | 296 | { |
| 297 | 297 | $file=$postData['file']; |
| 298 | - $fileHandler=@fopen($file,'w'); |
|
| 298 | + $fileHandler=@fopen($file, 'w'); |
|
| 299 | 299 | if ($fileHandler == false) |
| 300 | 300 | { // File os note writabe / cannot create |
| 301 | 301 | $this->_helper->json(array('status'=>'File not writable : '.$file)); |
@@ -315,17 +315,17 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - $level = $this->checkPostVar($postData, 'level', '[0-9]'); |
|
| 318 | + $level=$this->checkPostVar($postData, 'level', '[0-9]'); |
|
| 319 | 319 | |
| 320 | 320 | try |
| 321 | 321 | { |
| 322 | - $this->getUIDatabase()->setDBConfigValue('log_destination',$destination); |
|
| 323 | - $this->getUIDatabase()->setDBConfigValue('log_file',$file); |
|
| 324 | - $this->getUIDatabase()->setDBConfigValue('log_level',$level); |
|
| 322 | + $this->getUIDatabase()->setDBConfigValue('log_destination', $destination); |
|
| 323 | + $this->getUIDatabase()->setDBConfigValue('log_file', $file); |
|
| 324 | + $this->getUIDatabase()->setDBConfigValue('log_level', $level); |
|
| 325 | 325 | } |
| 326 | 326 | catch (Exception $e) |
| 327 | 327 | { |
| 328 | - $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
|
| 328 | + $this->_helper->json(array('status'=>'Save error : '.$e->getMessage())); |
|
| 329 | 329 | return; |
| 330 | 330 | } |
| 331 | 331 | $this->_helper->json(array('status'=>'OK')); |
@@ -343,29 +343,29 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | $postData=$this->getRequest()->getPost(); |
| 345 | 345 | |
| 346 | - $rule = $this->checkPostVar($postData, 'rule', '.*'); |
|
| 346 | + $rule=$this->checkPostVar($postData, 'rule', '.*'); |
|
| 347 | 347 | |
| 348 | - $action = $this->checkPostVar($postData, 'action', 'evaluate'); |
|
| 348 | + $action=$this->checkPostVar($postData, 'action', 'evaluate'); |
|
| 349 | 349 | |
| 350 | 350 | if ($action == 'evaluate') |
| 351 | 351 | { |
| 352 | 352 | try |
| 353 | 353 | { |
| 354 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 354 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 355 | 355 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 356 | - $trap = new Trap($icingaweb2_etc); |
|
| 356 | + $trap=new Trap($icingaweb2_etc); |
|
| 357 | 357 | // Cleanup spaces before eval |
| 358 | 358 | $rule=$trap->ruleClass->eval_cleanup($rule); |
| 359 | 359 | // Eval |
| 360 | 360 | $item=0; |
| 361 | - $rule=$trap->ruleClass->evaluation($rule,$item); |
|
| 361 | + $rule=$trap->ruleClass->evaluation($rule, $item); |
|
| 362 | 362 | } |
| 363 | 363 | catch (Exception $e) |
| 364 | 364 | { |
| 365 | - $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() )); |
|
| 365 | + $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage())); |
|
| 366 | 366 | return; |
| 367 | 367 | } |
| 368 | - $return=($rule==true)?'true':'false'; |
|
| 368 | + $return=($rule == true) ? 'true' : 'false'; |
|
| 369 | 369 | $this->_helper->json(array('status'=>'OK', 'message' => $return)); |
| 370 | 370 | } |
| 371 | 371 | |
@@ -380,15 +380,15 @@ discard block |
||
| 380 | 380 | { |
| 381 | 381 | $postData=$this->getRequest()->getPost(); |
| 382 | 382 | |
| 383 | - $pluginName = $this->checkPostVar($postData, 'name', '.*'); |
|
| 383 | + $pluginName=$this->checkPostVar($postData, 'name', '.*'); |
|
| 384 | 384 | |
| 385 | - $action = $this->checkPostVar($postData, 'action', 'enable|disable'); |
|
| 385 | + $action=$this->checkPostVar($postData, 'action', 'enable|disable'); |
|
| 386 | 386 | |
| 387 | 387 | try |
| 388 | 388 | { |
| 389 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 389 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 390 | 390 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 391 | - $trap = new Trap($icingaweb2_etc); |
|
| 391 | + $trap=new Trap($icingaweb2_etc); |
|
| 392 | 392 | // Enable plugin. |
| 393 | 393 | $action=($action == 'enable') ? true : false; |
| 394 | 394 | $retVal=$trap->pluginClass->enablePlugin($pluginName, $action); |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | } |
| 397 | 397 | catch (Exception $e) |
| 398 | 398 | { |
| 399 | - $this->_helper->json(array('status'=>'Action error : '.$e->getMessage() )); |
|
| 399 | + $this->_helper->json(array('status'=>'Action error : '.$e->getMessage())); |
|
| 400 | 400 | return; |
| 401 | 401 | } |
| 402 | 402 | if ($retVal === true) |
@@ -418,45 +418,45 @@ discard block |
||
| 418 | 418 | { |
| 419 | 419 | $postData=$this->getRequest()->getPost(); |
| 420 | 420 | |
| 421 | - $functionString = $this->checkPostVar($postData, 'function', '.*'); |
|
| 421 | + $functionString=$this->checkPostVar($postData, 'function', '.*'); |
|
| 422 | 422 | |
| 423 | 423 | $this->checkPostVar($postData, 'action', 'evaluate'); |
| 424 | 424 | |
| 425 | 425 | // Only one action possible for now, no tests on action. |
| 426 | 426 | try |
| 427 | 427 | { |
| 428 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 428 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 429 | 429 | $icingaweb2Etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 430 | - $trap = new Trap($icingaweb2Etc); |
|
| 430 | + $trap=new Trap($icingaweb2Etc); |
|
| 431 | 431 | // load all plugins in case tested function is not enabled. |
| 432 | 432 | $trap->pluginClass->registerAllPlugins(false); |
| 433 | 433 | // Clean all spaces |
| 434 | - $functionString = $trap->ruleClass->eval_cleanup($functionString); |
|
| 434 | + $functionString=$trap->ruleClass->eval_cleanup($functionString); |
|
| 435 | 435 | // Eval functions |
| 436 | - $result = $trap->pluginClass->evaluateFunctionString($functionString); |
|
| 436 | + $result=$trap->pluginClass->evaluateFunctionString($functionString); |
|
| 437 | 437 | } |
| 438 | 438 | catch (Exception $e) |
| 439 | 439 | { |
| 440 | - $this->_helper->json(array('status'=>'Action error : '.$e->getMessage() )); |
|
| 440 | + $this->_helper->json(array('status'=>'Action error : '.$e->getMessage())); |
|
| 441 | 441 | return; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - $result = ($result === true)?'True':'False'; |
|
| 445 | - $this->_helper->json(array('status'=>'OK','message' => $result)); |
|
| 444 | + $result=($result === true) ? 'True' : 'False'; |
|
| 445 | + $this->_helper->json(array('status'=>'OK', 'message' => $result)); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /************** Utilities **********************/ |
| 449 | 449 | |
| 450 | - private function checkPostVar(array $postData,string $postVar, string $validRegexp) : string |
|
| 450 | + private function checkPostVar(array $postData, string $postVar, string $validRegexp) : string |
|
| 451 | 451 | { |
| 452 | 452 | if (!isset ($postData[$postVar])) |
| 453 | 453 | { |
| 454 | - $this->_helper->json(array('status'=>'No ' . $postVar)); |
|
| 454 | + $this->_helper->json(array('status'=>'No '.$postVar)); |
|
| 455 | 455 | return ''; |
| 456 | 456 | } |
| 457 | 457 | if (preg_match('/'.$validRegexp.'/', $postData[$postVar]) != 1) |
| 458 | 458 | { |
| 459 | - $this->_helper->json(array('status'=>'Unknown ' . $postVar . ' value '.$postData[$postVar])); |
|
| 459 | + $this->_helper->json(array('status'=>'Unknown '.$postVar.' value '.$postData[$postVar])); |
|
| 460 | 460 | return ''; |
| 461 | 461 | } |
| 462 | 462 | return $postData[$postVar]; |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | $this->checkReadPermission(); |
| 24 | 24 | $this->prepareTabs()->activate('status'); |
| 25 | 25 | |
| 26 | - $dbConn = $this->getUIDatabase()->getDb(); |
|
| 26 | + $dbConn=$this->getUIDatabase()->getDb(); |
|
| 27 | 27 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 28 | 28 | |
| 29 | 29 | $this->getHandlerListTable()->setConnection($dbConn); |
| 30 | 30 | $this->getHandlerListTable()->setMibloader($this->getMIB()); |
| 31 | 31 | // Apply pagination limits |
| 32 | - $this->view->table=$this->applyPaginationLimits($this->getHandlerListTable(),$this->getModuleConfig()->itemListDisplay()); |
|
| 32 | + $this->view->table=$this->applyPaginationLimits($this->getHandlerListTable(), $this->getModuleConfig()->itemListDisplay()); |
|
| 33 | 33 | |
| 34 | 34 | // Set Filter |
| 35 | - $this->view->filterEditor = $this->getHandlerListTable()->getFilterEditor($this->getRequest()); |
|
| 35 | + $this->view->filterEditor=$this->getHandlerListTable()->getFilterEditor($this->getRequest()); |
|
| 36 | 36 | |
| 37 | 37 | //$this->displayExitError('Handler/indexAction','Not implemented'); |
| 38 | 38 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | public function testruleAction() |
| 43 | 43 | { |
| 44 | 44 | $this->checkReadPermission(); |
| 45 | - $this->getTabs()->add('get',array( |
|
| 45 | + $this->getTabs()->add('get', array( |
|
| 46 | 46 | 'active' => true, |
| 47 | 47 | 'label' => $this->translate('Test Rule'), |
| 48 | 48 | 'url' => Url::fromRequest() |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | if ($this->params->get('rule') !== null) |
| 53 | 53 | { |
| 54 | - $this->view->rule= $this->params->get('rule'); |
|
| 54 | + $this->view->rule=$this->params->get('rule'); |
|
| 55 | 55 | } |
| 56 | 56 | else |
| 57 | 57 | { |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | catch (Exception $e) |
| 112 | 112 | { |
| 113 | - $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage()); |
|
| 113 | + $this->displayExitError('Add handler : get host by IP/Name ', $e->getMessage()); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | // if one unique host found -> put id text input |
| 118 | - if (count($hosts)==1) { |
|
| 118 | + if (count($hosts) == 1) { |
|
| 119 | 119 | $this->view->hostname=$hosts[0]->name; |
| 120 | 120 | //$hostid=$hosts[0]->id; |
| 121 | 121 | // Tell JS to get services when page is loaded |
@@ -124,9 +124,9 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | else |
| 126 | 126 | { |
| 127 | - foreach($hosts as $key=>$val) |
|
| 127 | + foreach ($hosts as $key=>$val) |
|
| 128 | 128 | { |
| 129 | - array_push($this->view->hostlist,$hosts[$key]->name); |
|
| 129 | + array_push($this->view->hostlist, $hosts[$key]->name); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | $currentObjectTypeEnum |
| 166 | 166 | ); |
| 167 | 167 | $oid_index++; |
| 168 | - array_push($this->view->objectList,$currentObject); |
|
| 168 | + array_push($this->view->objectList, $currentObject); |
|
| 169 | 169 | // set currrent object to null in allObjects |
| 170 | 170 | if (isset($allObjects[$val->oid])) |
| 171 | 171 | { |
| 172 | 172 | $allObjects[$val->oid]=null; |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | - if ($allObjects!=null) // in case trap doesn't have objects or is not resolved |
|
| 175 | + if ($allObjects != null) // 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 | 180 | array_push($this->view->objectList, array( |
| 181 | 181 | $oid_index, |
| 182 | 182 | $key, |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | // Check if hostname still exists |
| 205 | 205 | $host_get=$this->getHostByName($this->view->hostname); |
| 206 | 206 | |
| 207 | - if (count($host_get)==0) |
|
| 207 | + if (count($host_get) == 0) |
|
| 208 | 208 | { |
| 209 | - $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore'; |
|
| 209 | + $this->view->warning_message='Host '.$this->view->hostname.' doesn\'t exists anymore'; |
|
| 210 | 210 | $this->view->serviceGet=false; |
| 211 | 211 | } |
| 212 | 212 | else |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | // Tell JS to get services when page is loaded |
| 215 | 215 | $this->view->serviceGet=true; |
| 216 | 216 | // get service id for form to set : |
| 217 | - $serviceID=$this->getServiceIDByName($this->view->hostname,$ruleDetail->service_name); |
|
| 218 | - if (count($serviceID) ==0) |
|
| 217 | + $serviceID=$this->getServiceIDByName($this->view->hostname, $ruleDetail->service_name); |
|
| 218 | + if (count($serviceID) == 0) |
|
| 219 | 219 | { |
| 220 | - $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
|
| 220 | + $this->view->warning_message=' Service '.$ruleDetail->service_name.' doesn\'t exists anymore'; |
|
| 221 | 221 | } |
| 222 | 222 | else |
| 223 | 223 | { |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | { |
| 235 | 235 | // Check if groupe exists |
| 236 | 236 | $group_get=$this->getHostGroupByName($this->view->hostgroupname); |
| 237 | - if (count($group_get)==0) |
|
| 237 | + if (count($group_get) == 0) |
|
| 238 | 238 | { |
| 239 | - $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore'; |
|
| 239 | + $this->view->warning_message='HostGroup '.$this->view->hostgroupname.' doesn\'t exists anymore'; |
|
| 240 | 240 | $this->view->serviceGroupGet=false; |
| 241 | 241 | } |
| 242 | 242 | else |
@@ -254,9 +254,9 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | // Tell JS to get services when page is loaded |
| 256 | 256 | $this->view->serviceGroupGet=true; |
| 257 | - if ($foundGrpService==0) |
|
| 257 | + if ($foundGrpService == 0) |
|
| 258 | 258 | { |
| 259 | - $this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
|
| 259 | + $this->view->warning_message.=' Service '.$ruleDetail->service_name.' doesn\'t exists anymore'; |
|
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | } |
@@ -274,12 +274,12 @@ discard block |
||
| 274 | 274 | $index=1; |
| 275 | 275 | // check in display & rule for : OID(<oid>) |
| 276 | 276 | $matches=array(); |
| 277 | - while ( preg_match('/_OID\(([\.0-9\*]+)\)/',$display,$matches) || |
|
| 278 | - preg_match('/_OID\(([\.0-9\*]+)\)/',$rule,$matches)) |
|
| 277 | + while (preg_match('/_OID\(([\.0-9\*]+)\)/', $display, $matches) || |
|
| 278 | + preg_match('/_OID\(([\.0-9\*]+)\)/', $rule, $matches)) |
|
| 279 | 279 | { |
| 280 | 280 | $curOid=$matches[1]; |
| 281 | 281 | |
| 282 | - if ( (preg_match('/\*/',$curOid) == 0 ) |
|
| 282 | + if ((preg_match('/\*/', $curOid) == 0) |
|
| 283 | 283 | && ($object=$this->getMIB()->translateOID($curOid)) != null) |
| 284 | 284 | { |
| 285 | 285 | array_push($curObjectList, array( |
@@ -304,9 +304,9 @@ discard block |
||
| 304 | 304 | 'not found' |
| 305 | 305 | )); |
| 306 | 306 | } |
| 307 | - $curOid = preg_replace('/\*/','\*',$curOid); |
|
| 308 | - $display=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$display); |
|
| 309 | - $rule=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$rule); |
|
| 307 | + $curOid=preg_replace('/\*/', '\*', $curOid); |
|
| 308 | + $display=preg_replace('/_OID\('.$curOid.'\)/', '\$'.$index.'\$', $display); |
|
| 309 | + $rule=preg_replace('/_OID\('.$curOid.'\)/', '\$'.$index.'\$', $rule); |
|
| 310 | 310 | $index++; |
| 311 | 311 | } |
| 312 | 312 | return $curObjectList; |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | { |
| 321 | 321 | $this->checkConfigPermission(); |
| 322 | 322 | // set up tab |
| 323 | - $this->getTabs()->add('get',array( |
|
| 323 | + $this->getTabs()->add('get', array( |
|
| 324 | 324 | 'active' => true, |
| 325 | 325 | 'label' => $this->translate('Add handler'), |
| 326 | 326 | 'url' => Url::fromRequest() |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | //$this->view->trapvalues=false; // Set to true to display 'value' colum in objects |
| 335 | 335 | |
| 336 | - if (($trapid = $this->params->get('fromid')) !== null) { |
|
| 336 | + if (($trapid=$this->params->get('fromid')) !== null) { |
|
| 337 | 337 | /********** Setup from existing trap ***************/ |
| 338 | 338 | $this->add_from_existing($trapid); |
| 339 | 339 | return; |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | $this->view->setRuleMatch=$ruleDetail->action_match; |
| 354 | 354 | $this->view->setRuleNoMatch=$ruleDetail->action_nomatch; |
| 355 | 355 | $this->view->hostgroupname=$ruleDetail->host_group_name; |
| 356 | - $this->view->modified=gmdate("Y-m-d\TH:i:s\Z",$ruleDetail->modified); |
|
| 356 | + $this->view->modified=gmdate("Y-m-d\TH:i:s\Z", $ruleDetail->modified); |
|
| 357 | 357 | $this->view->modifier=$ruleDetail->modifier; |
| 358 | 358 | |
| 359 | 359 | // Warning message if host/service don't exists anymore |
@@ -405,26 +405,26 @@ discard block |
||
| 405 | 405 | |
| 406 | 406 | $params=array( |
| 407 | 407 | // id (also db) => array('post' => post id, 'val' => default val, 'db' => send to table) |
| 408 | - 'hostgroup' => array('post' => 'hostgroup','db'=>false), |
|
| 409 | - 'db_rule' => array('post' => 'db_rule','db'=>false), |
|
| 410 | - 'hostid' => array('post' => 'hostid','db'=>false), |
|
| 411 | - 'host_name' => array('post' => 'hostname','val' => null,'db'=>true), |
|
| 412 | - 'host_group_name'=> array('post' => null,'val' => null,'db'=>true), |
|
| 413 | - 'serviceid' => array('post' => 'serviceid','db'=>false), |
|
| 414 | - 'service_name' => array('post' => 'serviceName','db'=>true), |
|
| 415 | - 'trap_oid' => array('post' => 'oid','db'=>true), |
|
| 416 | - 'revert_ok' => array('post' => 'revertOK','val' => 0,'db'=>true), |
|
| 417 | - 'display' => array('post' => 'display','val' => '','db'=>true), |
|
| 418 | - 'rule' => array('post' => 'rule','val' => '','db'=>true), |
|
| 419 | - 'action_match' => array('post' => 'ruleMatch','val' => -1,'db'=>true), |
|
| 420 | - 'action_nomatch'=> array('post' => 'ruleNoMatch','val' => -1,'db'=>true), |
|
| 421 | - 'ip4' => array('post' => null,'val' => null,'db'=>true), |
|
| 422 | - 'ip6' => array('post' => null,'val' => null,'db'=>true), |
|
| 423 | - 'action_form' => array('post' => 'action_form','db'=>false) |
|
| 408 | + 'hostgroup' => array('post' => 'hostgroup', 'db'=>false), |
|
| 409 | + 'db_rule' => array('post' => 'db_rule', 'db'=>false), |
|
| 410 | + 'hostid' => array('post' => 'hostid', 'db'=>false), |
|
| 411 | + 'host_name' => array('post' => 'hostname', 'val' => null, 'db'=>true), |
|
| 412 | + 'host_group_name'=> array('post' => null, 'val' => null, 'db'=>true), |
|
| 413 | + 'serviceid' => array('post' => 'serviceid', 'db'=>false), |
|
| 414 | + 'service_name' => array('post' => 'serviceName', 'db'=>true), |
|
| 415 | + 'trap_oid' => array('post' => 'oid', 'db'=>true), |
|
| 416 | + 'revert_ok' => array('post' => 'revertOK', 'val' => 0, 'db'=>true), |
|
| 417 | + 'display' => array('post' => 'display', 'val' => '', 'db'=>true), |
|
| 418 | + 'rule' => array('post' => 'rule', 'val' => '', 'db'=>true), |
|
| 419 | + 'action_match' => array('post' => 'ruleMatch', 'val' => -1, 'db'=>true), |
|
| 420 | + 'action_nomatch'=> array('post' => 'ruleNoMatch', 'val' => -1, 'db'=>true), |
|
| 421 | + 'ip4' => array('post' => null, 'val' => null, 'db'=>true), |
|
| 422 | + 'ip6' => array('post' => null, 'val' => null, 'db'=>true), |
|
| 423 | + 'action_form' => array('post' => 'action_form', 'db'=>false) |
|
| 424 | 424 | ); |
| 425 | 425 | |
| 426 | 426 | if (isset($postData[$params['action_form']['post']]) |
| 427 | - && $postData[$params['action_form']['post']] == 'delete' ) |
|
| 427 | + && $postData[$params['action_form']['post']] == 'delete') |
|
| 428 | 428 | { |
| 429 | 429 | try |
| 430 | 430 | { |
@@ -444,16 +444,16 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | foreach (array_keys($params) as $key) |
| 446 | 446 | { |
| 447 | - if ($params[$key]['post']==null) continue; // data not sent in post vars |
|
| 448 | - if (! isset($postData[$params[$key]['post']])) |
|
| 447 | + if ($params[$key]['post'] == null) continue; // data not sent in post vars |
|
| 448 | + if (!isset($postData[$params[$key]['post']])) |
|
| 449 | 449 | { |
| 450 | 450 | // should not happen as the js checks data |
| 451 | - $this->_helper->json(array('status'=>'No ' . $key)); |
|
| 451 | + $this->_helper->json(array('status'=>'No '.$key)); |
|
| 452 | 452 | } |
| 453 | 453 | else |
| 454 | 454 | { |
| 455 | 455 | $data=$postData[$params[$key]['post']]; |
| 456 | - if ($data!=null && $data !="") |
|
| 456 | + if ($data != null && $data != "") |
|
| 457 | 457 | { |
| 458 | 458 | $params[$key]['val']=$postData[$params[$key]['post']]; |
| 459 | 459 | } |
@@ -462,8 +462,8 @@ discard block |
||
| 462 | 462 | |
| 463 | 463 | try |
| 464 | 464 | { |
| 465 | - $isHostGroup=($params['hostgroup']['val'] == 1)?true:false; |
|
| 466 | - if (! $isHostGroup ) |
|
| 465 | + $isHostGroup=($params['hostgroup']['val'] == 1) ?true:false; |
|
| 466 | + if (!$isHostGroup) |
|
| 467 | 467 | { // checks if selection by host |
| 468 | 468 | $hostAddr=$this->getHostInfoByID($params['hostid']['val']); |
| 469 | 469 | $params['ip4']['val']=$hostAddr->ip4; |
@@ -490,25 +490,25 @@ discard block |
||
| 490 | 490 | return; |
| 491 | 491 | } |
| 492 | 492 | // Put param in correct column (group_name) |
| 493 | - $params['host_group_name']['val'] = $params['host_name']['val']; |
|
| 493 | + $params['host_group_name']['val']=$params['host_name']['val']; |
|
| 494 | 494 | $params['host_name']['val']=null; |
| 495 | 495 | } |
| 496 | 496 | $dbparams=array(); |
| 497 | 497 | foreach ($params as $key=>$val) |
| 498 | 498 | { |
| 499 | - if ($val['db']==true ) |
|
| 499 | + if ($val['db'] == true) |
|
| 500 | 500 | { |
| 501 | - $dbparams[$key] = $val['val']; |
|
| 501 | + $dbparams[$key]=$val['val']; |
|
| 502 | 502 | } |
| 503 | 503 | } |
| 504 | 504 | // echo '<br>'; print_r($dbparams);echo '<br>'; |
| 505 | - if ($params['db_rule']['val'] == -1 ) |
|
| 505 | + if ($params['db_rule']['val'] == -1) |
|
| 506 | 506 | { |
| 507 | 507 | $ruleID=$this->getUIDatabase()->addHandlerRule($dbparams); |
| 508 | 508 | } |
| 509 | 509 | else |
| 510 | 510 | { |
| 511 | - $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']); |
|
| 511 | + $this->getUIDatabase()->updateHandlerRule($dbparams, $params['db_rule']['val']); |
|
| 512 | 512 | $ruleID=$params['db_rule']['val']; |
| 513 | 513 | } |
| 514 | 514 | } |
@@ -527,10 +527,10 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | protected function getTrapDetail($trapid) |
| 529 | 529 | { |
| 530 | - if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id'); } |
|
| 530 | + if (!preg_match('/^[0-9]+$/', $trapid)) { throw new Exception('Invalid id'); } |
|
| 531 | 531 | $queryArray=$this->getModuleConfig()->trapDetailQuery(); |
| 532 | 532 | |
| 533 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 533 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 534 | 534 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 535 | 535 | // *************** Get main data |
| 536 | 536 | // extract columns and titles; |
@@ -540,19 +540,19 @@ discard block |
||
| 540 | 540 | } |
| 541 | 541 | try |
| 542 | 542 | { |
| 543 | - $query = $dbConn->select() |
|
| 544 | - ->from($this->getModuleConfig()->getTrapTableName(),$elmts) |
|
| 545 | - ->where('id=?',$trapid); |
|
| 543 | + $query=$dbConn->select() |
|
| 544 | + ->from($this->getModuleConfig()->getTrapTableName(), $elmts) |
|
| 545 | + ->where('id=?', $trapid); |
|
| 546 | 546 | $trapDetail=$dbConn->fetchRow($query); |
| 547 | - if ( $trapDetail == null ) |
|
| 547 | + if ($trapDetail == null) |
|
| 548 | 548 | { |
| 549 | - $trapDetail = 'NULL'; |
|
| 549 | + $trapDetail='NULL'; |
|
| 550 | 550 | throw new Exception('No traps was found with id = '.$trapid); |
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | 553 | catch (Exception $e) |
| 554 | 554 | { |
| 555 | - $this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail,true),$e->getMessage()); |
|
| 555 | + $this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail, true), $e->getMessage()); |
|
| 556 | 556 | return; |
| 557 | 557 | } |
| 558 | 558 | |
@@ -566,10 +566,10 @@ discard block |
||
| 566 | 566 | */ |
| 567 | 567 | protected function getTrapobjects($trapid) |
| 568 | 568 | { |
| 569 | - if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id'); } |
|
| 569 | + if (!preg_match('/^[0-9]+$/', $trapid)) { throw new Exception('Invalid id'); } |
|
| 570 | 570 | $queryArrayData=$this->getModuleConfig()->trapDataDetailQuery(); |
| 571 | 571 | |
| 572 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 572 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 573 | 573 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 574 | 574 | // *************** Get object data |
| 575 | 575 | // extract columns and titles; |
@@ -579,15 +579,15 @@ discard block |
||
| 579 | 579 | } |
| 580 | 580 | try |
| 581 | 581 | { |
| 582 | - $query = $dbConn->select() |
|
| 583 | - ->from($this->moduleConfig->getTrapDataTableName(),$data_elmts) |
|
| 584 | - ->where('trap_id=?',$trapid); |
|
| 582 | + $query=$dbConn->select() |
|
| 583 | + ->from($this->moduleConfig->getTrapDataTableName(), $data_elmts) |
|
| 584 | + ->where('trap_id=?', $trapid); |
|
| 585 | 585 | $trapDetail=$dbConn->fetchAll($query); |
| 586 | 586 | // if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid); |
| 587 | 587 | } |
| 588 | 588 | catch (Exception $e) |
| 589 | 589 | { |
| 590 | - $this->displayExitError('Add handler : get trap data detail : ',$e->getMessage()); |
|
| 590 | + $this->displayExitError('Add handler : get trap data detail : ', $e->getMessage()); |
|
| 591 | 591 | return array(); |
| 592 | 592 | } |
| 593 | 593 | |
@@ -601,24 +601,24 @@ discard block |
||
| 601 | 601 | */ |
| 602 | 602 | protected function getRuleDetail($ruleid) |
| 603 | 603 | { |
| 604 | - if (!preg_match('/^[0-9]+$/',$ruleid)) { throw new Exception('Invalid id'); } |
|
| 604 | + if (!preg_match('/^[0-9]+$/', $ruleid)) { throw new Exception('Invalid id'); } |
|
| 605 | 605 | $queryArray=$this->getModuleConfig()->ruleDetailQuery(); |
| 606 | 606 | |
| 607 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 607 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 608 | 608 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 609 | 609 | // *************** Get main data |
| 610 | 610 | try |
| 611 | 611 | { |
| 612 | - $query = $dbConn->select() |
|
| 613 | - ->from($this->getModuleConfig()->getTrapRuleName(),$queryArray) |
|
| 614 | - ->where('id=?',$ruleid); |
|
| 612 | + $query=$dbConn->select() |
|
| 613 | + ->from($this->getModuleConfig()->getTrapRuleName(), $queryArray) |
|
| 614 | + ->where('id=?', $ruleid); |
|
| 615 | 615 | $ruleDetail=$dbConn->fetchRow($query); |
| 616 | - if ( $ruleDetail == null ) throw new Exception('No rule was found with id = '.$ruleid); |
|
| 616 | + if ($ruleDetail == null) throw new Exception('No rule was found with id = '.$ruleid); |
|
| 617 | 617 | } |
| 618 | 618 | catch (Exception $e) |
| 619 | 619 | { |
| 620 | - $this->displayExitError('Update handler : get rule detail',$e->getMessage()); |
|
| 621 | - throw new Exception('Error : ',$e->getMessage()); |
|
| 620 | + $this->displayExitError('Update handler : get rule detail', $e->getMessage()); |
|
| 621 | + throw new Exception('Error : ', $e->getMessage()); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | return $ruleDetail; |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | { |
| 632 | 632 | return $this->getTabs()->add('status', array( |
| 633 | 633 | 'label' => $this->translate('Traps'), |
| 634 | - 'url' => $this->getModuleConfig()->urlPath() . '/handler') |
|
| 634 | + 'url' => $this->getModuleConfig()->urlPath().'/handler') |
|
| 635 | 635 | ); |
| 636 | 636 | } |
| 637 | 637 | |
@@ -20,20 +20,20 @@ discard block |
||
| 20 | 20 | $this->checkReadPermission(); |
| 21 | 21 | $this->prepareTabs()->activate('traps'); |
| 22 | 22 | |
| 23 | - $dbConn = $this->getUIDatabase()->getDb(); |
|
| 23 | + $dbConn=$this->getUIDatabase()->getDb(); |
|
| 24 | 24 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 25 | 25 | $this->getTrapListTable()->setConnection($dbConn); |
| 26 | 26 | |
| 27 | 27 | // Apply pagination limits |
| 28 | - $this->view->table=$this->applyPaginationLimits($this->getTrapListTable(),$this->getModuleConfig()->itemListDisplay()); |
|
| 28 | + $this->view->table=$this->applyPaginationLimits($this->getTrapListTable(), $this->getModuleConfig()->itemListDisplay()); |
|
| 29 | 29 | |
| 30 | 30 | // Set Filter |
| 31 | 31 | //$postData=$this->getRequest()->getPost(); |
| 32 | 32 | $filter=array(); |
| 33 | - $filter['q']=$this->params->get('q');//(isset($postData['q']))?$postData['q']:''; |
|
| 33 | + $filter['q']=$this->params->get('q'); //(isset($postData['q']))?$postData['q']:''; |
|
| 34 | 34 | $filter['done']=$this->params->get('done'); |
| 35 | 35 | $this->view->filter=$filter; |
| 36 | - $this->view->table->updateFilter(Url::fromRequest(),$filter); |
|
| 36 | + $this->view->table->updateFilter(Url::fromRequest(), $filter); |
|
| 37 | 37 | |
| 38 | 38 | //$this->view->filterEditor = $this->getTrapListTable()->getFilterEditor($this->getRequest()); |
| 39 | 39 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $this->checkReadPermission(); |
| 49 | 49 | // set up tab |
| 50 | - $this->getTabs()->add('get',array( |
|
| 50 | + $this->getTabs()->add('get', array( |
|
| 51 | 51 | 'active' => true, |
| 52 | 52 | 'label' => $this->translate('Detailed status'), |
| 53 | 53 | 'url' => Url::fromRequest() |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | $this->view->trapid=$trapid; |
| 58 | 58 | $queryArray=$this->getModuleConfig()->trapDetailQuery(); |
| 59 | 59 | |
| 60 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 60 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 61 | 61 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 62 | 62 | |
| 63 | 63 | // URL to add a handler |
| 64 | 64 | $this->view->addHandlerUrl=Url::fromPath( |
| 65 | - $this->getModuleConfig()->urlPath() . '/handler/add', |
|
| 65 | + $this->getModuleConfig()->urlPath().'/handler/add', |
|
| 66 | 66 | array('fromid' => $trapid)); |
| 67 | 67 | // *************** Get main data |
| 68 | 68 | // extract columns and titles; |
@@ -74,28 +74,28 @@ discard block |
||
| 74 | 74 | // Do DB query for trap. |
| 75 | 75 | try |
| 76 | 76 | { |
| 77 | - $query = $dbConn->select() |
|
| 78 | - ->from($this->moduleConfig->getTrapTableName(),$elmts) |
|
| 79 | - ->where('id=?',$trapid); |
|
| 77 | + $query=$dbConn->select() |
|
| 78 | + ->from($this->moduleConfig->getTrapTableName(), $elmts) |
|
| 79 | + ->where('id=?', $trapid); |
|
| 80 | 80 | $trapDetail=$dbConn->fetchRow($query); |
| 81 | - if ( $trapDetail == null) throw new Exception('No traps was found with id = '.$trapid); |
|
| 81 | + if ($trapDetail == null) throw new Exception('No traps was found with id = '.$trapid); |
|
| 82 | 82 | } |
| 83 | 83 | catch (Exception $e) |
| 84 | 84 | { |
| 85 | - $this->displayExitError('Trap detail',$e->getMessage()); |
|
| 85 | + $this->displayExitError('Trap detail', $e->getMessage()); |
|
| 86 | 86 | return; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Store result in array (with Titles). |
| 90 | 90 | foreach ($queryArray as $key => $val) { |
| 91 | 91 | if ($key == 'timestamp') { |
| 92 | - $cval=strftime('%c',$trapDetail->$key); |
|
| 92 | + $cval=strftime('%c', $trapDetail->$key); |
|
| 93 | 93 | } else { |
| 94 | 94 | $cval=$trapDetail->$key; |
| 95 | 95 | } |
| 96 | - array_push($queryArray[$key],$cval); |
|
| 96 | + array_push($queryArray[$key], $cval); |
|
| 97 | 97 | } |
| 98 | - $this->view->rowset = $queryArray; |
|
| 98 | + $this->view->rowset=$queryArray; |
|
| 99 | 99 | |
| 100 | 100 | // ************** Check for additionnal data |
| 101 | 101 | |
@@ -107,17 +107,17 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | try |
| 109 | 109 | { |
| 110 | - $query = $dbConn->select() |
|
| 111 | - ->from($this->moduleConfig->getTrapDataTableName(),$data_elmts) |
|
| 112 | - ->where('trap_id=?',$trapid); |
|
| 110 | + $query=$dbConn->select() |
|
| 111 | + ->from($this->moduleConfig->getTrapDataTableName(), $data_elmts) |
|
| 112 | + ->where('trap_id=?', $trapid); |
|
| 113 | 113 | $trapDetail=$dbConn->fetchAll($query); |
| 114 | 114 | } |
| 115 | 115 | catch (Exception $e) |
| 116 | 116 | { |
| 117 | - $this->displayExitError('Trap detail',$e->getMessage()); |
|
| 117 | + $this->displayExitError('Trap detail', $e->getMessage()); |
|
| 118 | 118 | } |
| 119 | 119 | // TODO : code this in a better & simpler way |
| 120 | - if ($trapDetail == null ) |
|
| 120 | + if ($trapDetail == null) |
|
| 121 | 121 | { |
| 122 | 122 | $this->view->data=false; |
| 123 | 123 | } |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | foreach ($trapDetail as $key => $val) |
| 130 | 130 | { |
| 131 | 131 | $trapval[$key]=array(); |
| 132 | - foreach (array_keys($queryArrayData) as $vkey ) |
|
| 132 | + foreach (array_keys($queryArrayData) as $vkey) |
|
| 133 | 133 | { |
| 134 | - array_push($trapval[$key],$val->$vkey); |
|
| 134 | + array_push($trapval[$key], $val->$vkey); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | $this->view->data_val=$trapval; |
@@ -147,21 +147,21 @@ discard block |
||
| 147 | 147 | $this->checkReadPermission(); |
| 148 | 148 | $this->prepareTabs()->activate('hosts'); |
| 149 | 149 | |
| 150 | - $dbConn = $this->getUIDatabase()->getDb(); |
|
| 150 | + $dbConn=$this->getUIDatabase()->getDb(); |
|
| 151 | 151 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 152 | 152 | |
| 153 | 153 | $this->getTrapHostListTable()->setConnection($dbConn); |
| 154 | 154 | |
| 155 | 155 | // Apply pagination limits |
| 156 | - $this->view->table=$this->applyPaginationLimits($this->getTrapHostListTable(),$this->getModuleConfig()->itemListDisplay()); |
|
| 156 | + $this->view->table=$this->applyPaginationLimits($this->getTrapHostListTable(), $this->getModuleConfig()->itemListDisplay()); |
|
| 157 | 157 | |
| 158 | 158 | // Set Filter |
| 159 | 159 | //$postData=$this->getRequest()->getPost(); |
| 160 | 160 | $filter=array(); |
| 161 | - $filter['q']=$this->params->get('q');//(isset($postData['q']))?$postData['q']:''; |
|
| 161 | + $filter['q']=$this->params->get('q'); //(isset($postData['q']))?$postData['q']:''; |
|
| 162 | 162 | $filter['done']=$this->params->get('done'); |
| 163 | 163 | $this->view->filter=$filter; |
| 164 | - $this->view->table->updateFilter(Url::fromRequest(),$filter); |
|
| 164 | + $this->view->table->updateFilter(Url::fromRequest(), $filter); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | public function deleteAction() |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | return $this->getTabs()->add('traps', array( |
| 182 | 182 | 'label' => $this->translate('Traps'), |
| 183 | - 'url' => $this->getModuleConfig()->urlPath() . '/received') |
|
| 183 | + 'url' => $this->getModuleConfig()->urlPath().'/received') |
|
| 184 | 184 | ) |
| 185 | 185 | ->add('hosts', array( |
| 186 | 186 | 'label' => $this->translate('Hosts'), |
| 187 | - 'url' => $this->getModuleConfig()->urlPath() . '/received/hosts') |
|
| 187 | + 'url' => $this->getModuleConfig()->urlPath().'/received/hosts') |
|
| 188 | 188 | ) |
| 189 | 189 | ->add('delete', array( |
| 190 | 190 | 'label' => $this->translate('Delete'), |
| 191 | - 'url' => $this->getModuleConfig()->urlPath() . '/received/delete') |
|
| 191 | + 'url' => $this->getModuleConfig()->urlPath().'/received/delete') |
|
| 192 | 192 | ); |
| 193 | 193 | } |
| 194 | 194 | |
@@ -215,14 +215,14 @@ discard block |
||
| 215 | 215 | $this->_helper->json(array('status'=>'Missing variables')); |
| 216 | 216 | return; |
| 217 | 217 | } |
| 218 | - if ($action =="count") |
|
| 218 | + if ($action == "count") |
|
| 219 | 219 | { |
| 220 | - $this->_helper->json(array('status'=>'OK','count'=>$this->getUIDatabase()->countTrap($ip,$oid))); |
|
| 220 | + $this->_helper->json(array('status'=>'OK', 'count'=>$this->getUIDatabase()->countTrap($ip, $oid))); |
|
| 221 | 221 | return; |
| 222 | 222 | } |
| 223 | - if ($action =="delete") |
|
| 223 | + if ($action == "delete") |
|
| 224 | 224 | { |
| 225 | - $this->_helper->json(array('status'=>'OK','count'=>$this->getUIDatabase()->deleteTrap($ip,$oid))); |
|
| 225 | + $this->_helper->json(array('status'=>'OK', 'count'=>$this->getUIDatabase()->deleteTrap($ip, $oid))); |
|
| 226 | 226 | return; |
| 227 | 227 | } |
| 228 | 228 | $this->_helper->json(array('status'=>'unknown action')); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $this->redirectNow('trapdirector/settings?message=No database prefix'); |
| 56 | 56 | } |
| 57 | - $this->moduleConfig = new TrapModuleConfig($db_prefix); |
|
| 57 | + $this->moduleConfig=new TrapModuleConfig($db_prefix); |
|
| 58 | 58 | } |
| 59 | 59 | return $this->moduleConfig; |
| 60 | 60 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | public function getTrapListTable() { |
| 67 | 67 | if ($this->trapTableList == Null) { |
| 68 | - $this->trapTableList = new TrapTableList(); |
|
| 68 | + $this->trapTableList=new TrapTableList(); |
|
| 69 | 69 | $this->trapTableList->setConfig($this->getModuleConfig()); |
| 70 | 70 | } |
| 71 | 71 | return $this->trapTableList; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | if ($this->trapTableHostList == Null) |
| 80 | 80 | { |
| 81 | - $this->trapTableHostList = new TrapTableHostList(); |
|
| 81 | + $this->trapTableHostList=new TrapTableHostList(); |
|
| 82 | 82 | $this->trapTableHostList->setConfig($this->getModuleConfig()); |
| 83 | 83 | } |
| 84 | 84 | return $this->trapTableHostList; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | if ($this->handlerTableList == Null) |
| 93 | 93 | { |
| 94 | - $this->handlerTableList = new HandlerTableList(); |
|
| 94 | + $this->handlerTableList=new HandlerTableList(); |
|
| 95 | 95 | $this->handlerTableList->setConfig($this->getModuleConfig()); |
| 96 | 96 | } |
| 97 | 97 | return $this->handlerTableList; |
@@ -104,38 +104,38 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | if ($this->UIDatabase == Null) |
| 106 | 106 | { |
| 107 | - $this->UIDatabase = new UIDatabase($this); |
|
| 107 | + $this->UIDatabase=new UIDatabase($this); |
|
| 108 | 108 | |
| 109 | 109 | } |
| 110 | 110 | return $this->UIDatabase; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null) |
|
| 113 | + protected function applyPaginationLimits(Paginatable $paginatable, $limit=25, $offset=null) |
|
| 114 | 114 | { |
| 115 | - $limit = $this->params->get('limit', $limit); |
|
| 116 | - $page = $this->params->get('page', $offset); |
|
| 115 | + $limit=$this->params->get('limit', $limit); |
|
| 116 | + $page=$this->params->get('page', $offset); |
|
| 117 | 117 | |
| 118 | 118 | $paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0); |
| 119 | 119 | |
| 120 | 120 | return $paginatable; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public function displayExitError($source,$message) |
|
| 123 | + public function displayExitError($source, $message) |
|
| 124 | 124 | { // TODO : check better ways to transmit data (with POST ?) |
| 125 | 125 | $this->redirectNow('trapdirector/error?source='.$source.'&message='.$message); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | protected function checkReadPermission() |
| 129 | 129 | { |
| 130 | - if (! $this->Auth()->hasPermission('trapdirector/view')) { |
|
| 131 | - $this->displayExitError('Permissions','No permission fo view content'); |
|
| 130 | + if (!$this->Auth()->hasPermission('trapdirector/view')) { |
|
| 131 | + $this->displayExitError('Permissions', 'No permission fo view content'); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | protected function checkConfigPermission() |
| 136 | 136 | { |
| 137 | - if (! $this->Auth()->hasPermission('trapdirector/config')) { |
|
| 138 | - $this->displayExitError('Permissions','No permission fo configure'); |
|
| 137 | + if (!$this->Auth()->hasPermission('trapdirector/config')) { |
|
| 138 | + $this->displayExitError('Permissions', 'No permission fo configure'); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | protected function checkModuleConfigPermission($check=0) |
| 148 | 148 | { |
| 149 | - if (! $this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 149 | + if (!$this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 150 | 150 | if ($check == 0) |
| 151 | 151 | { |
| 152 | - $this->displayExitError('Permissions','No permission fo configure module'); |
|
| 152 | + $this->displayExitError('Permissions', 'No permission fo configure module'); |
|
| 153 | 153 | } |
| 154 | 154 | return false; |
| 155 | 155 | } |
@@ -161,10 +161,10 @@ discard block |
||
| 161 | 161 | { // TODO : try/catch here ? or within caller |
| 162 | 162 | if ($this->trapClass == null) |
| 163 | 163 | { |
| 164 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 164 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 165 | 165 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 166 | 166 | //$debug_level=4; |
| 167 | - $this->trapClass = new Trap($icingaweb2_etc); |
|
| 167 | + $this->trapClass=new Trap($icingaweb2_etc); |
|
| 168 | 168 | //$Trap->setLogging($debug_level,'syslog'); |
| 169 | 169 | } |
| 170 | 170 | return $this->trapClass; |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | { |
| 180 | 180 | if ($this->MIBData == null) |
| 181 | 181 | { |
| 182 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 182 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 183 | 183 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 184 | 184 | $this->MIBData=new MIBLoader( |
| 185 | 185 | $this->Config()->get('config', 'snmptranslate'), |
@@ -200,14 +200,14 @@ discard block |
||
| 200 | 200 | protected function getHostByIP($ip) |
| 201 | 201 | { |
| 202 | 202 | // select a.name1, b.display_name from icinga.icinga_objects AS a , icinga.icinga_hosts AS b WHERE (b.address = '192.168.56.101' OR b.address6= '123456') and b.host_object_id=a.object_id |
| 203 | - $dbConn = $this->getUIDatabase()->getIdoDbConn(); |
|
| 203 | + $dbConn=$this->getUIDatabase()->getIdoDbConn(); |
|
| 204 | 204 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 205 | 205 | |
| 206 | 206 | // TODO : check for SQL injections |
| 207 | 207 | $query=$dbConn->select() |
| 208 | 208 | ->from( |
| 209 | 209 | array('a' => 'icinga_objects'), |
| 210 | - array('name' => 'a.name1','id' => 'object_id')) |
|
| 210 | + array('name' => 'a.name1', 'id' => 'object_id')) |
|
| 211 | 211 | ->join( |
| 212 | 212 | array('b' => 'icinga_hosts'), |
| 213 | 213 | 'b.host_object_id=a.object_id', |
@@ -223,14 +223,14 @@ discard block |
||
| 223 | 223 | protected function getHostByName($name) |
| 224 | 224 | { |
| 225 | 225 | // select a.name1, b.display_name from icinga.icinga_objects AS a , icinga.icinga_hosts AS b WHERE (b.address = '192.168.56.101' OR b.address6= '123456') and b.host_object_id=a.object_id |
| 226 | - $dbConn = $this->getUIDatabase()->getIdoDbConn(); |
|
| 226 | + $dbConn=$this->getUIDatabase()->getIdoDbConn(); |
|
| 227 | 227 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 228 | 228 | |
| 229 | 229 | // TODO : check for SQL injections |
| 230 | 230 | $query=$dbConn->select() |
| 231 | 231 | ->from( |
| 232 | 232 | array('a' => 'icinga_objects'), |
| 233 | - array('name' => 'a.name1','id' => 'object_id')) |
|
| 233 | + array('name' => 'a.name1', 'id' => 'object_id')) |
|
| 234 | 234 | ->join( |
| 235 | 235 | array('b' => 'icinga_hosts'), |
| 236 | 236 | 'b.host_object_id=a.object_id', |
@@ -246,13 +246,13 @@ discard block |
||
| 246 | 246 | protected function getHostGroupByName($ip) |
| 247 | 247 | { |
| 248 | 248 | // select a.name1, b.display_name from icinga.icinga_objects AS a , icinga.icinga_hosts AS b WHERE (b.address = '192.168.56.101' OR b.address6= '123456') and b.host_object_id=a.object_id |
| 249 | - $dbConn = $this->getUIDatabase()->getIdoDbConn(); |
|
| 249 | + $dbConn=$this->getUIDatabase()->getIdoDbConn(); |
|
| 250 | 250 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 251 | 251 | // TODO : check for SQL injections |
| 252 | 252 | $query=$dbConn->select() |
| 253 | 253 | ->from( |
| 254 | 254 | array('a' => 'icinga_objects'), |
| 255 | - array('name' => 'a.name1','id' => 'object_id')) |
|
| 255 | + array('name' => 'a.name1', 'id' => 'object_id')) |
|
| 256 | 256 | ->join( |
| 257 | 257 | array('b' => 'icinga_hostgroups'), |
| 258 | 258 | 'b.hostgroup_object_id=a.object_id', |
@@ -268,8 +268,8 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | protected function getHostInfoByID($id) |
| 270 | 270 | { |
| 271 | - if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
|
| 272 | - $dbConn = $this->getUIDatabase()->getIdoDbConn(); |
|
| 271 | + if (!preg_match('/^[0-9]+$/', $id)) { throw new Exception('Invalid id'); } |
|
| 272 | + $dbConn=$this->getUIDatabase()->getIdoDbConn(); |
|
| 273 | 273 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 274 | 274 | $query=$dbConn->select() |
| 275 | 275 | ->from( |
@@ -290,18 +290,18 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | protected function getHostByObjectID($id) // TODO : duplicate of getHostInfoByID above |
| 292 | 292 | { |
| 293 | - if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
|
| 294 | - $dbConn = $this->getUIDatabase()->getIdoDbConn(); |
|
| 293 | + if (!preg_match('/^[0-9]+$/', $id)) { throw new Exception('Invalid id'); } |
|
| 294 | + $dbConn=$this->getUIDatabase()->getIdoDbConn(); |
|
| 295 | 295 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 296 | 296 | $query=$dbConn->select() |
| 297 | 297 | ->from( |
| 298 | 298 | array('a' => 'icinga_objects'), |
| 299 | - array('name' => 'a.name1','id' => 'a.object_id')) |
|
| 299 | + array('name' => 'a.name1', 'id' => 'a.object_id')) |
|
| 300 | 300 | ->join( |
| 301 | 301 | array('b' => 'icinga_hosts'), |
| 302 | 302 | 'b.host_object_id=a.object_id', |
| 303 | - array('display_name' => 'b.display_name' , 'ip' => 'b.address', 'ip6' => 'b.address6')) |
|
| 304 | - ->where('a.object_id = ?',$id); |
|
| 303 | + array('display_name' => 'b.display_name', 'ip' => 'b.address', 'ip6' => 'b.address6')) |
|
| 304 | + ->where('a.object_id = ?', $id); |
|
| 305 | 305 | return $dbConn->fetchRow($query); |
| 306 | 306 | } |
| 307 | 307 | |
@@ -313,17 +313,17 @@ discard block |
||
| 313 | 313 | protected function getServicesByHostid($id) |
| 314 | 314 | { |
| 315 | 315 | // select a.name1, b.display_name from icinga.icinga_objects AS a , icinga.icinga_hosts AS b WHERE (b.address = '192.168.56.101' OR b.address6= '123456') and b.host_object_id=a.object_id |
| 316 | - if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
|
| 317 | - $dbConn = $this->getUIDatabase()->getIdoDbConn(); |
|
| 316 | + if (!preg_match('/^[0-9]+$/', $id)) { throw new Exception('Invalid id'); } |
|
| 317 | + $dbConn=$this->getUIDatabase()->getIdoDbConn(); |
|
| 318 | 318 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 319 | 319 | $query=$dbConn->select() |
| 320 | 320 | ->from( |
| 321 | 321 | array('s' => 'icinga_services'), |
| 322 | - array('name' => 's.display_name','id' => 's.service_object_id')) |
|
| 322 | + array('name' => 's.display_name', 'id' => 's.service_object_id')) |
|
| 323 | 323 | ->join( |
| 324 | 324 | array('a' => 'icinga_objects'), |
| 325 | 325 | 's.service_object_id=a.object_id', |
| 326 | - array('is_active'=>'a.is_active','name2'=>'a.name2')) |
|
| 326 | + array('is_active'=>'a.is_active', 'name2'=>'a.name2')) |
|
| 327 | 327 | ->where('s.host_object_id='.$id.' AND a.is_active = 1'); |
| 328 | 328 | return $dbConn->fetchAll($query); |
| 329 | 329 | } |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | */ |
| 337 | 337 | protected function getServicesByHostGroupid($id) |
| 338 | 338 | { |
| 339 | - if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
|
| 340 | - $dbConn = $this->getUIDatabase()->getIdoDbConn(); |
|
| 339 | + if (!preg_match('/^[0-9]+$/', $id)) { throw new Exception('Invalid id'); } |
|
| 340 | + $dbConn=$this->getUIDatabase()->getIdoDbConn(); |
|
| 341 | 341 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 342 | 342 | $query=$dbConn->select() |
| 343 | 343 | ->from( |
@@ -354,11 +354,11 @@ discard block |
||
| 354 | 354 | foreach ($hosts as $key => $host) |
| 355 | 355 | { // For each host, get all services and add in common_services if not found or add counter |
| 356 | 356 | $host_services=$this->getServicesByHostid($host->host_object_id); |
| 357 | - foreach($host_services as $service) |
|
| 357 | + foreach ($host_services as $service) |
|
| 358 | 358 | { |
| 359 | 359 | if (isset($common_services[$service->name2]['num'])) |
| 360 | 360 | { |
| 361 | - $common_services[$service->name2]['num'] +=1; |
|
| 361 | + $common_services[$service->name2]['num']+=1; |
|
| 362 | 362 | } |
| 363 | 363 | else |
| 364 | 364 | { |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | { |
| 375 | 375 | if ($common_services[$key]['num'] == $num_hosts) |
| 376 | 376 | { |
| 377 | - array_push($result,array($key,$common_services[$key]['name'])); |
|
| 377 | + array_push($result, array($key, $common_services[$key]['name'])); |
|
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | |
@@ -387,9 +387,9 @@ discard block |
||
| 387 | 387 | * @param $name string service name |
| 388 | 388 | * @return array service id |
| 389 | 389 | */ |
| 390 | - protected function getServiceIDByName($hostname,$name) |
|
| 390 | + protected function getServiceIDByName($hostname, $name) |
|
| 391 | 391 | { |
| 392 | - $dbConn = $this->getUIDatabase()->getIdoDbConn(); |
|
| 392 | + $dbConn=$this->getUIDatabase()->getIdoDbConn(); |
|
| 393 | 393 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 394 | 394 | |
| 395 | 395 | if ($name == null) |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | $query=$dbConn->select() |
| 401 | 401 | ->from( |
| 402 | 402 | array('s' => 'icinga_services'), |
| 403 | - array('name' => 's.display_name','id' => 's.service_object_id')) |
|
| 403 | + array('name' => 's.display_name', 'id' => 's.service_object_id')) |
|
| 404 | 404 | ->join( |
| 405 | 405 | array('a' => 'icinga_objects'), |
| 406 | 406 | 's.service_object_id=a.object_id', |
@@ -418,14 +418,14 @@ discard block |
||
| 418 | 418 | protected function getObjectNameByid($id) |
| 419 | 419 | { |
| 420 | 420 | // select a.name1, b.display_name from icinga.icinga_objects AS a , icinga.icinga_hosts AS b WHERE (b.address = '192.168.56.101' OR b.address6= '123456') and b.host_object_id=a.object_id |
| 421 | - if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
|
| 422 | - $dbConn = $this->getUIDatabase()->getIdoDbConn(); |
|
| 421 | + if (!preg_match('/^[0-9]+$/', $id)) { throw new Exception('Invalid id'); } |
|
| 422 | + $dbConn=$this->getUIDatabase()->getIdoDbConn(); |
|
| 423 | 423 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 424 | 424 | |
| 425 | 425 | $query=$dbConn->select() |
| 426 | 426 | ->from( |
| 427 | 427 | array('a' => 'icinga_objects'), |
| 428 | - array('name1' => 'a.name1','name2' => 'a.name2')) |
|
| 428 | + array('name1' => 'a.name1', 'name2' => 'a.name2')) |
|
| 429 | 429 | ->where('a.object_id='.$id.' AND a.is_active = 1'); |
| 430 | 430 | |
| 431 | 431 | return $dbConn->fetchRow($query); |
@@ -437,10 +437,10 @@ discard block |
||
| 437 | 437 | protected function isDirectorInstalled() |
| 438 | 438 | { |
| 439 | 439 | $output=array(); |
| 440 | - exec('icingacli module list',$output); |
|
| 440 | + exec('icingacli module list', $output); |
|
| 441 | 441 | foreach ($output as $line) |
| 442 | 442 | { |
| 443 | - if (preg_match('/^director .*enabled/',$line)) |
|
| 443 | + if (preg_match('/^director .*enabled/', $line)) |
|
| 444 | 444 | { |
| 445 | 445 | return true; |
| 446 | 446 | } |
@@ -29,18 +29,18 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | // TODO Check for rule consistency |
| 31 | 31 | |
| 32 | - $dbConn = $this->getDbConn(); |
|
| 32 | + $dbConn=$this->getDbConn(); |
|
| 33 | 33 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 34 | 34 | // Add last modified date = creation date and username |
| 35 | - $params['created'] = new Zend_Db_Expr('NOW()'); |
|
| 36 | - $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 37 | - $params['modifier'] = $this->Auth()->getUser()->getUsername(); |
|
| 35 | + $params['created']=new Zend_Db_Expr('NOW()'); |
|
| 36 | + $params['modified']=new Zend_Db_Expr('NOW()'); |
|
| 37 | + $params['modifier']=$this->Auth()->getUser()->getUsername(); |
|
| 38 | 38 | |
| 39 | 39 | $query=$dbConn->insert( |
| 40 | 40 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
| 41 | 41 | $params |
| 42 | 42 | ); |
| 43 | - if($query==false) |
|
| 43 | + if ($query == false) |
|
| 44 | 44 | { |
| 45 | 45 | return null; |
| 46 | 46 | } |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | * @param integer $ruleID : rule id in db |
| 53 | 53 | * @return array affected rows |
| 54 | 54 | */ |
| 55 | - public function updateHandlerRule($params,$ruleID) |
|
| 55 | + public function updateHandlerRule($params, $ruleID) |
|
| 56 | 56 | { |
| 57 | 57 | // TODO Check for rule consistency |
| 58 | - $dbConn = $this->getDbConn(); |
|
| 58 | + $dbConn=$this->getDbConn(); |
|
| 59 | 59 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 60 | 60 | // Add last modified date = creation date and username |
| 61 | - $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 62 | - $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 61 | + $params['modified']=new Zend_Db_Expr('NOW()'); |
|
| 62 | + $params['modifier']=$this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 63 | 63 | |
| 64 | 64 | $numRows=$dbConn->update( |
| 65 | 65 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function deleteRule($ruleID) |
| 76 | 76 | { |
| 77 | - if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id'); } |
|
| 77 | + if (!preg_match('/^[0-9]+$/', $ruleID)) { throw new Exception('Invalid id'); } |
|
| 78 | 78 | |
| 79 | - $dbConn = $this->getDbConn(); |
|
| 79 | + $dbConn=$this->getDbConn(); |
|
| 80 | 80 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 81 | 81 | |
| 82 | 82 | $query=$dbConn->delete( |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | * @param $ip string source IP (v4 or v6) |
| 91 | 91 | * @param $oid string oid |
| 92 | 92 | */ |
| 93 | - public function deleteTrap($ip,$oid) |
|
| 93 | + public function deleteTrap($ip, $oid) |
|
| 94 | 94 | { |
| 95 | 95 | |
| 96 | - $dbConn = $this->getDbConn(); |
|
| 96 | + $dbConn=$this->getDbConn(); |
|
| 97 | 97 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 98 | 98 | $condition=null; |
| 99 | 99 | if ($ip != null) |
@@ -102,10 +102,10 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | if ($oid != null) |
| 104 | 104 | { |
| 105 | - $condition=($condition===null)?'':$condition.' AND '; |
|
| 105 | + $condition=($condition === null) ? '' : $condition.' AND '; |
|
| 106 | 106 | $condition.="trap_oid='$oid'"; |
| 107 | 107 | } |
| 108 | - if($condition === null) return null; |
|
| 108 | + if ($condition === null) return null; |
|
| 109 | 109 | $query=$dbConn->delete( |
| 110 | 110 | $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
| 111 | 111 | $condition |
@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | * @param $ip string source IP (v4 or v6) |
| 120 | 120 | * @param $oid string oid |
| 121 | 121 | */ |
| 122 | - public function countTrap($ip,$oid) |
|
| 122 | + public function countTrap($ip, $oid) |
|
| 123 | 123 | { |
| 124 | 124 | |
| 125 | - $dbConn = $this->getDbConn(); |
|
| 125 | + $dbConn=$this->getDbConn(); |
|
| 126 | 126 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 127 | 127 | |
| 128 | 128 | $condition=null; |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | if ($oid != null) |
| 134 | 134 | { |
| 135 | - $condition=($condition===null)?'':$condition.' AND '; |
|
| 135 | + $condition=($condition === null) ? '' : $condition.' AND '; |
|
| 136 | 136 | $condition.="trap_oid='$oid'"; |
| 137 | 137 | } |
| 138 | - if($condition === null) return 0; |
|
| 138 | + if ($condition === null) return 0; |
|
| 139 | 139 | $query=$dbConn->select() |
| 140 | 140 | ->from( |
| 141 | 141 | $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
@@ -151,28 +151,28 @@ discard block |
||
| 151 | 151 | public function getDBConfigValue($element) |
| 152 | 152 | { |
| 153 | 153 | |
| 154 | - $dbConn = $this->getDbConn(); |
|
| 154 | + $dbConn=$this->getDbConn(); |
|
| 155 | 155 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 156 | 156 | |
| 157 | 157 | $query=$dbConn->select() |
| 158 | 158 | ->from( |
| 159 | 159 | $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
| 160 | 160 | array('value'=>'value')) |
| 161 | - ->where('name=?',$element); |
|
| 161 | + ->where('name=?', $element); |
|
| 162 | 162 | $return_row=$dbConn->fetchRow($query); |
| 163 | - if ($return_row==null) // value does not exists |
|
| 163 | + if ($return_row == null) // value does not exists |
|
| 164 | 164 | { |
| 165 | 165 | $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
| 166 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 166 | + if (!isset($default[$element])) return null; // no default and not value |
|
| 167 | 167 | |
| 168 | - $this->addDBConfigValue($element,$default[$element]); |
|
| 168 | + $this->addDBConfigValue($element, $default[$element]); |
|
| 169 | 169 | return $default[$element]; |
| 170 | 170 | } |
| 171 | 171 | if ($return_row->value == null) // value id empty |
| 172 | 172 | { |
| 173 | 173 | $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
| 174 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 175 | - $this->setDBConfigValue($element,$default[$element]); |
|
| 174 | + if (!isset($default[$element])) return null; // no default and not value |
|
| 175 | + $this->setDBConfigValue($element, $default[$element]); |
|
| 176 | 176 | return $default[$element]; |
| 177 | 177 | } |
| 178 | 178 | return $return_row->value; |
@@ -183,10 +183,10 @@ discard block |
||
| 183 | 183 | * @param string $value : value |
| 184 | 184 | */ |
| 185 | 185 | |
| 186 | - public function addDBConfigValue($element,$value) |
|
| 186 | + public function addDBConfigValue($element, $value) |
|
| 187 | 187 | { |
| 188 | 188 | |
| 189 | - $dbConn = $this->getDbConn(); |
|
| 189 | + $dbConn=$this->getDbConn(); |
|
| 190 | 190 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 191 | 191 | |
| 192 | 192 | $query=$dbConn->insert( |
@@ -203,10 +203,10 @@ discard block |
||
| 203 | 203 | * @param string $element : name of config element |
| 204 | 204 | * @param string $value : value |
| 205 | 205 | */ |
| 206 | - public function setDBConfigValue($element,$value) |
|
| 206 | + public function setDBConfigValue($element, $value) |
|
| 207 | 207 | { |
| 208 | 208 | |
| 209 | - $dbConn = $this->getDbConn(); |
|
| 209 | + $dbConn=$this->getDbConn(); |
|
| 210 | 210 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 211 | 211 | |
| 212 | 212 | $query=$dbConn->update( |