@@ -20,22 +20,22 @@ discard block |
||
| 20 | 20 | protected $MIB; |
| 21 | 21 | |
| 22 | 22 | // categories |
| 23 | - protected $categories = NULL; |
|
| 23 | + protected $categories=NULL; |
|
| 24 | 24 | |
| 25 | 25 | public function setCategoriesArray(array $categories) |
| 26 | 26 | { |
| 27 | - $this->categories = $categories; |
|
| 27 | + $this->categories=$categories; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function groupingPrintData( $value) |
|
| 30 | + public function groupingPrintData($value) |
|
| 31 | 31 | { |
| 32 | 32 | if ($this->groupingColumn == 'rule_type') |
| 33 | 33 | { |
| 34 | - if ($this->categories == NULL || (! isset($this->categories[$value]))) |
|
| 34 | + if ($this->categories == NULL || (!isset($this->categories[$value]))) |
|
| 35 | 35 | return 'Unknown category ('.$value.')'; |
| 36 | - return 'Category : '. $this->categories[$value]; |
|
| 36 | + return 'Category : '.$this->categories[$value]; |
|
| 37 | 37 | } |
| 38 | - $html = "$value"; |
|
| 38 | + $html="$value"; |
|
| 39 | 39 | return $html; |
| 40 | 40 | } |
| 41 | 41 | |
@@ -58,16 +58,16 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | public function getCurrentURL() |
| 60 | 60 | { |
| 61 | - return Url::fromPath($this->urlPath . '/handler'); |
|
| 61 | + return Url::fromPath($this->urlPath.'/handler'); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | public function renderLine($row) |
| 65 | 65 | { |
| 66 | - $html = ''; |
|
| 67 | - $firstCol = true; |
|
| 66 | + $html=''; |
|
| 67 | + $firstCol=true; |
|
| 68 | 68 | |
| 69 | - $titleNames = array_keys($this->titles); |
|
| 70 | - foreach ($titleNames as $rowkey ) |
|
| 69 | + $titleNames=array_keys($this->titles); |
|
| 70 | + foreach ($titleNames as $rowkey) |
|
| 71 | 71 | { |
| 72 | 72 | // Check missing value |
| 73 | 73 | if (property_exists($row, $rowkey)) |
@@ -82,57 +82,57 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | if ($this->doTranslate === true) |
| 84 | 84 | { |
| 85 | - $oidName = $this->MIB->translateOID($row->$rowkey); |
|
| 85 | + $oidName=$this->MIB->translateOID($row->$rowkey); |
|
| 86 | 86 | if (isset($oidName['name'])) |
| 87 | 87 | { |
| 88 | 88 | $val=$oidName['name']; |
| 89 | 89 | } |
| 90 | 90 | else |
| 91 | 91 | { |
| 92 | - $val = $row->$rowkey; |
|
| 92 | + $val=$row->$rowkey; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | else |
| 96 | 96 | { |
| 97 | - $val = $row->$rowkey; |
|
| 97 | + $val=$row->$rowkey; |
|
| 98 | 98 | } |
| 99 | 99 | break; |
| 100 | 100 | case 'host_name': // switch to hostgroup if name is null |
| 101 | 101 | if ($row->$rowkey == null) |
| 102 | 102 | { |
| 103 | - $val = $row->host_group_name; |
|
| 103 | + $val=$row->host_group_name; |
|
| 104 | 104 | } |
| 105 | 105 | else |
| 106 | 106 | { |
| 107 | - $val = $row->$rowkey; |
|
| 107 | + $val=$row->$rowkey; |
|
| 108 | 108 | } |
| 109 | 109 | break; |
| 110 | 110 | default: |
| 111 | - $val = $row->$rowkey; |
|
| 111 | + $val=$row->$rowkey; |
|
| 112 | 112 | } |
| 113 | - if ($rowkey == 'trap_oid' && $this->doTranslate===true) |
|
| 113 | + if ($rowkey == 'trap_oid' && $this->doTranslate === true) |
|
| 114 | 114 | { |
| 115 | 115 | |
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | - $val = '-'; |
|
| 118 | + $val='-'; |
|
| 119 | 119 | } |
| 120 | 120 | if ($firstCol === true) { // Put link in first column for trap detail. |
| 121 | - $html .= '<td class="traphover">' |
|
| 121 | + $html.='<td class="traphover">' |
|
| 122 | 122 | . $this->view->qlink( |
| 123 | 123 | $this->view->escape($val), |
| 124 | 124 | Url::fromPath( |
| 125 | - $this->urlPath . '/handler/add', |
|
| 125 | + $this->urlPath.'/handler/add', |
|
| 126 | 126 | array('ruleid' => $row->id) |
| 127 | 127 | ) |
| 128 | 128 | ); |
| 129 | 129 | if ($row->comment != '') |
| 130 | 130 | { |
| 131 | - $html.= '<span class="tohover">'. $row->comment .'</span></td>'; |
|
| 131 | + $html.='<span class="tohover">'.$row->comment.'</span></td>'; |
|
| 132 | 132 | } |
| 133 | - $html.= '</td>'; |
|
| 133 | + $html.='</td>'; |
|
| 134 | 134 | } else { |
| 135 | - $html .= '<td>' . $this->view->escape($val) . '</td>'; |
|
| 135 | + $html.='<td>'.$this->view->escape($val).'</td>'; |
|
| 136 | 136 | } |
| 137 | 137 | $firstCol=false; |
| 138 | 138 | |
@@ -6,16 +6,16 @@ discard block |
||
| 6 | 6 | abstract class TrapDirectorTable |
| 7 | 7 | { |
| 8 | 8 | /** @var array $titles table titles (name, display value) */ |
| 9 | - protected $titles = null; |
|
| 9 | + protected $titles=null; |
|
| 10 | 10 | |
| 11 | 11 | /** @var array $content table content (name, sb column name). name index must be the same as $titles*/ |
| 12 | - protected $content = null; |
|
| 12 | + protected $content=null; |
|
| 13 | 13 | |
| 14 | 14 | /** @var array $columnNames names of columns for filtering */ |
| 15 | - protected $columnNames = array(); |
|
| 15 | + protected $columnNames=array(); |
|
| 16 | 16 | |
| 17 | 17 | /** @var mixed $dbConn connection to database */ |
| 18 | - protected $dbConn = null; |
|
| 18 | + protected $dbConn=null; |
|
| 19 | 19 | |
| 20 | 20 | /** Current view **/ |
| 21 | 21 | protected $view; |
@@ -24,28 +24,28 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | // Database stuff |
| 26 | 26 | /** @var array $table (db ref, name) */ |
| 27 | - protected $table = array(); |
|
| 27 | + protected $table=array(); |
|
| 28 | 28 | |
| 29 | 29 | /** @var mixed $query Query in database; */ |
| 30 | - protected $query = null; |
|
| 30 | + protected $query=null; |
|
| 31 | 31 | |
| 32 | 32 | /** @var array $order : (db column, 'ASC' | 'DESC') */ |
| 33 | - protected $order = array(); |
|
| 34 | - protected $orderQuery = ''; |
|
| 33 | + protected $order=array(); |
|
| 34 | + protected $orderQuery=''; |
|
| 35 | 35 | |
| 36 | 36 | /********* Filter ********/ |
| 37 | 37 | /** @var string $filterString : string filter for db columns */ |
| 38 | - protected $filterString = ''; |
|
| 38 | + protected $filterString=''; |
|
| 39 | 39 | |
| 40 | 40 | /** @var array $filterColumn : columns to apply filter to */ |
| 41 | - protected $filterColumn = array(); |
|
| 41 | + protected $filterColumn=array(); |
|
| 42 | 42 | |
| 43 | 43 | protected $filterQuery=''; |
| 44 | 44 | |
| 45 | 45 | /*************** Paging *************/ |
| 46 | - protected $maxPerPage = 25; |
|
| 46 | + protected $maxPerPage=25; |
|
| 47 | 47 | |
| 48 | - protected $currentPage = 0; |
|
| 48 | + protected $currentPage=0; |
|
| 49 | 49 | |
| 50 | 50 | /*************** Grouping ************/ |
| 51 | 51 | protected $grouppingActive=false; |
@@ -56,16 +56,16 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | protected $groupingColSpan=1; |
| 58 | 58 | |
| 59 | - function __construct(array $table,array $titles, array $columns, array $columnNames, $dbConn , $view, $urlPath) |
|
| 59 | + function __construct(array $table, array $titles, array $columns, array $columnNames, $dbConn, $view, $urlPath) |
|
| 60 | 60 | { |
| 61 | - $this->table = $table; |
|
| 62 | - $this->titles = $titles; |
|
| 63 | - $this->content = $columns; |
|
| 64 | - $this->columnNames = $columnNames; |
|
| 65 | - $this->dbConn = $dbConn; |
|
| 61 | + $this->table=$table; |
|
| 62 | + $this->titles=$titles; |
|
| 63 | + $this->content=$columns; |
|
| 64 | + $this->columnNames=$columnNames; |
|
| 65 | + $this->dbConn=$dbConn; |
|
| 66 | 66 | |
| 67 | - $this->view = $view; |
|
| 68 | - $this->urlPath = $urlPath; |
|
| 67 | + $this->view=$view; |
|
| 68 | + $this->urlPath=$urlPath; |
|
| 69 | 69 | |
| 70 | 70 | return $this; |
| 71 | 71 | } |
@@ -86,19 +86,19 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | protected function getCurrentURLAndQS(string $caller) |
| 88 | 88 | { |
| 89 | - $actionURL = $this->getCurrentURL() . '?' ; |
|
| 89 | + $actionURL=$this->getCurrentURL().'?'; |
|
| 90 | 90 | $QSList=array(); |
| 91 | 91 | if ($caller != 'filter' && $this->curFilterQuery() != '') |
| 92 | - array_push($QSList , $this->curFilterQuery()); |
|
| 92 | + array_push($QSList, $this->curFilterQuery()); |
|
| 93 | 93 | |
| 94 | 94 | if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') |
| 95 | - array_push($QSList , $this->curPagingQuery()); |
|
| 95 | + array_push($QSList, $this->curPagingQuery()); |
|
| 96 | 96 | |
| 97 | 97 | if ($caller != 'order' && $this->curOrderQuery() != '') |
| 98 | - array_push($QSList , $this->curOrderQuery()); |
|
| 98 | + array_push($QSList, $this->curOrderQuery()); |
|
| 99 | 99 | |
| 100 | 100 | if (count($QSList) != 0) |
| 101 | - $actionURL .= implode('&', $QSList) . '&'; |
|
| 101 | + $actionURL.=implode('&', $QSList).'&'; |
|
| 102 | 102 | |
| 103 | 103 | return $actionURL; |
| 104 | 104 | } |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function getBaseQuery() |
| 112 | 112 | { |
| 113 | - $this->query = $this->dbConn->select(); |
|
| 114 | - $this->query = $this->query->from( |
|
| 113 | + $this->query=$this->dbConn->select(); |
|
| 114 | + $this->query=$this->query->from( |
|
| 115 | 115 | $this->table, |
| 116 | 116 | $this->content |
| 117 | 117 | ); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | { |
| 145 | 145 | if ($filter != "") $filter.=' OR '; |
| 146 | 146 | //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'"; |
| 147 | - $filter .= $column . " LIKE '%" . $this->filterString. "%'"; |
|
| 147 | + $filter.=$column." LIKE '%".$this->filterString."%'"; |
|
| 148 | 148 | } |
| 149 | 149 | //echo $filter; |
| 150 | 150 | |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | public function setFilter(string $filter, array $filterCol) |
| 157 | 157 | { |
| 158 | - $this->filterString = $filter; |
|
| 159 | - $this->filterColumn = $filterCol; |
|
| 158 | + $this->filterString=$filter; |
|
| 159 | + $this->filterColumn=$filterCol; |
|
| 160 | 160 | return $this; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | { |
| 179 | 179 | if (isset($getVars['f'])) |
| 180 | 180 | { |
| 181 | - $this->filterQuery = $getVars['f']; |
|
| 181 | + $this->filterQuery=$getVars['f']; |
|
| 182 | 182 | $this->setFilter(html_entity_decode($getVars['f']), $this->columnNames); |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -202,16 +202,16 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | if ($orderSQL != "") $orderSQL.=','; |
| 204 | 204 | |
| 205 | - $orderSQL .= $column . ' ' . $direction; |
|
| 205 | + $orderSQL.=$column.' '.$direction; |
|
| 206 | 206 | } |
| 207 | - $this->query = $this->query->order($orderSQL); |
|
| 207 | + $this->query=$this->query->order($orderSQL); |
|
| 208 | 208 | |
| 209 | 209 | return $this; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | public function setOrder(array $order) |
| 213 | 213 | { |
| 214 | - $this->order = $order; |
|
| 214 | + $this->order=$order; |
|
| 215 | 215 | return $this; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | { |
| 226 | 226 | if (isset($getVars['o'])) |
| 227 | 227 | { |
| 228 | - $this->orderQuery = $getVars['o']; |
|
| 229 | - $match = array(); |
|
| 230 | - if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match)) |
|
| 228 | + $this->orderQuery=$getVars['o']; |
|
| 229 | + $match=array(); |
|
| 230 | + if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery, $match)) |
|
| 231 | 231 | { |
| 232 | 232 | $orderArray=array($match[1] => $match[2]); |
| 233 | 233 | echo "$match[1] => $match[2]"; |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | public function countQuery() |
| 248 | 248 | { |
| 249 | - $this->query = $this->dbConn->select(); |
|
| 250 | - $this->query = $this->query |
|
| 249 | + $this->query=$this->dbConn->select(); |
|
| 250 | + $this->query=$this->query |
|
| 251 | 251 | ->from( |
| 252 | 252 | $this->table, |
| 253 | 253 | array('COUNT(*)') |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | public function setMaxPerPage(int $max) |
| 265 | 265 | { |
| 266 | - $this->maxPerPage = $max; |
|
| 266 | + $this->maxPerPage=$max; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | protected function getPagingQuery(array $getVars) |
| 270 | 270 | { |
| 271 | 271 | if (isset($getVars['page'])) |
| 272 | 272 | { |
| 273 | - $this->currentPage = $getVars['page']; |
|
| 273 | + $this->currentPage=$getVars['page']; |
|
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | |
@@ -282,22 +282,22 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | public function renderPagingHeader() |
| 284 | 284 | { |
| 285 | - $count = $this->count(); |
|
| 286 | - if ($count <= $this->maxPerPage ) |
|
| 285 | + $count=$this->count(); |
|
| 286 | + if ($count <= $this->maxPerPage) |
|
| 287 | 287 | { |
| 288 | - return 'count : ' . $this->count() . '<br>'; |
|
| 288 | + return 'count : '.$this->count().'<br>'; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if ($this->currentPage == 0) $this->currentPage = 1; |
|
| 291 | + if ($this->currentPage == 0) $this->currentPage=1; |
|
| 292 | 292 | |
| 293 | - $numPages = intdiv($count , $this->maxPerPage); |
|
| 294 | - if ($count % $this->maxPerPage != 0 ) $numPages++; |
|
| 293 | + $numPages=intdiv($count, $this->maxPerPage); |
|
| 294 | + if ($count % $this->maxPerPage != 0) $numPages++; |
|
| 295 | 295 | |
| 296 | - $html = '<div class="pagination-control" role="navigation">'; |
|
| 297 | - $html .= '<ul class="nav tab-nav">'; |
|
| 298 | - if ($this->currentPage <=1) |
|
| 296 | + $html='<div class="pagination-control" role="navigation">'; |
|
| 297 | + $html.='<ul class="nav tab-nav">'; |
|
| 298 | + if ($this->currentPage <= 1) |
|
| 299 | 299 | { |
| 300 | - $html .= ' |
|
| 300 | + $html.=' |
|
| 301 | 301 | <li class="nav-item disabled" aria-hidden="true"> |
| 302 | 302 | <span class="previous-page"> |
| 303 | 303 | <span class="sr-only">Previous page</span> |
@@ -308,24 +308,24 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | else |
| 310 | 310 | { |
| 311 | - $html .= ' |
|
| 311 | + $html.=' |
|
| 312 | 312 | <li class="nav-item"> |
| 313 | - <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage - 1 ).'" class="previous-page" > |
|
| 313 | + <a href="'. $this->getCurrentURLAndQS('paging').'&page='.($this->currentPage - 1).'" class="previous-page" > |
|
| 314 | 314 | <i aria-hidden="true" class="icon-angle-double-left"></i> |
| 315 | 315 | </a> |
| 316 | 316 | </li> |
| 317 | 317 | '; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - for ($i=1; $i <= $numPages ; $i++) |
|
| 320 | + for ($i=1; $i <= $numPages; $i++) |
|
| 321 | 321 | { |
| 322 | - $active = ($this->currentPage == $i) ? 'active' : ''; |
|
| 323 | - $first = ($i-1)*$this->maxPerPage+1; |
|
| 324 | - $last = $i * $this->maxPerPage; |
|
| 325 | - if ($last > $count) $last = $count; |
|
| 326 | - $display = 'Show rows '. $first . ' to '. $last .' of '. $count; |
|
| 327 | - $html .= '<li class="' . $active . ' nav-item"> |
|
| 328 | - <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '"> |
|
| 322 | + $active=($this->currentPage == $i) ? 'active' : ''; |
|
| 323 | + $first=($i - 1) * $this->maxPerPage + 1; |
|
| 324 | + $last=$i * $this->maxPerPage; |
|
| 325 | + if ($last > $count) $last=$count; |
|
| 326 | + $display='Show rows '.$first.' to '.$last.' of '.$count; |
|
| 327 | + $html.='<li class="'.$active.' nav-item"> |
|
| 328 | + <a href="'. $this->getCurrentURLAndQS('paging').'&page='.$i.'" title="'.$display.'" aria-label="'.$display.'"> |
|
| 329 | 329 | '.$i.' |
| 330 | 330 | </a> |
| 331 | 331 | </li>'; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | if ($this->currentPage == $numPages) |
| 335 | 335 | { |
| 336 | - $html .= ' |
|
| 336 | + $html.=' |
|
| 337 | 337 | <li class="nav-item disabled" aria-hidden="true"> |
| 338 | 338 | <span class="previous-page"> |
| 339 | 339 | <span class="sr-only">Previous page</span> |
@@ -344,23 +344,23 @@ discard block |
||
| 344 | 344 | } |
| 345 | 345 | else |
| 346 | 346 | { |
| 347 | - $html .= ' |
|
| 347 | + $html.=' |
|
| 348 | 348 | <li class="nav-item"> |
| 349 | - <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage + 1 ).'" class="next-page"> |
|
| 349 | + <a href="'. $this->getCurrentURLAndQS('paging').'&page='.($this->currentPage + 1).'" class="next-page"> |
|
| 350 | 350 | <i aria-hidden="true" class="icon-angle-double-right"></i> |
| 351 | 351 | </a> |
| 352 | 352 | </li> |
| 353 | 353 | '; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - $html .= '</ul> </div>'; |
|
| 356 | + $html.='</ul> </div>'; |
|
| 357 | 357 | |
| 358 | 358 | return $html; |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | public function applyPaging() |
| 362 | 362 | { |
| 363 | - $this->query->limitPage($this->currentPage,$this->maxPerPage); |
|
| 363 | + $this->query->limitPage($this->currentPage, $this->maxPerPage); |
|
| 364 | 364 | return $this; |
| 365 | 365 | } |
| 366 | 366 | |
@@ -368,31 +368,31 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | public function setGrouping($columnDBName) |
| 370 | 370 | { |
| 371 | - $this->groupingColumn = $columnDBName; |
|
| 372 | - $this->grouppingActive = TRUE; |
|
| 371 | + $this->groupingColumn=$columnDBName; |
|
| 372 | + $this->grouppingActive=TRUE; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | public function initGrouping() |
| 376 | 376 | { |
| 377 | - $this->groupingVal = ''; |
|
| 378 | - $this->groupingColSpan = count($this->titles); |
|
| 377 | + $this->groupingVal=''; |
|
| 378 | + $this->groupingColSpan=count($this->titles); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - public function groupingPrintData( $value) |
|
| 381 | + public function groupingPrintData($value) |
|
| 382 | 382 | { |
| 383 | - $html = "$value"; |
|
| 383 | + $html="$value"; |
|
| 384 | 384 | return $html; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - public function groupingNextLine( $values) |
|
| 387 | + public function groupingNextLine($values) |
|
| 388 | 388 | { |
| 389 | 389 | if ($this->grouppingActive === FALSE) return ''; |
| 390 | 390 | |
| 391 | - $dbcol = $this->groupingColumn; |
|
| 392 | - if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol ) |
|
| 391 | + $dbcol=$this->groupingColumn; |
|
| 392 | + if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol) |
|
| 393 | 393 | { |
| 394 | - $this->groupingVal = $values->$dbcol; |
|
| 395 | - $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>'; |
|
| 394 | + $this->groupingVal=$values->$dbcol; |
|
| 395 | + $html='<tr><th colspan="'.$this->groupingColSpan.'">'.$this->groupingPrintData($this->groupingVal).'</th></tr>'; |
|
| 396 | 396 | return $html; |
| 397 | 397 | } |
| 398 | 398 | return ''; |
@@ -408,10 +408,10 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | public function renderTitles() |
| 410 | 410 | { |
| 411 | - $html = "<thead>\n<tr>\n"; |
|
| 411 | + $html="<thead>\n<tr>\n"; |
|
| 412 | 412 | foreach ($this->titles as $name => $values) |
| 413 | 413 | { |
| 414 | - $titleOrder = $this->titleOrder($name); |
|
| 414 | + $titleOrder=$this->titleOrder($name); |
|
| 415 | 415 | if ($titleOrder != NULL) |
| 416 | 416 | { |
| 417 | 417 | if (isset($this->order[$titleOrder])) |
@@ -429,59 +429,59 @@ discard block |
||
| 429 | 429 | { |
| 430 | 430 | $titleOrder.='ASC'; |
| 431 | 431 | } |
| 432 | - $actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder; |
|
| 433 | - $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>'; |
|
| 432 | + $actionURL=$this->getCurrentURLAndQS('order').'o='.$titleOrder; |
|
| 433 | + $html.='<th><a href="'.$actionURL.'">'.$values.'</a></th>'; |
|
| 434 | 434 | } |
| 435 | 435 | else |
| 436 | 436 | { |
| 437 | - $html .= '<th>' . $values . '</th>'; |
|
| 437 | + $html.='<th>'.$values.'</th>'; |
|
| 438 | 438 | } |
| 439 | 439 | } |
| 440 | - $html .= "</tr>\n</thead>\n"; |
|
| 440 | + $html.="</tr>\n</thead>\n"; |
|
| 441 | 441 | return $html; |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - public function renderLine( $value) |
|
| 444 | + public function renderLine($value) |
|
| 445 | 445 | { |
| 446 | - $html = ''; |
|
| 447 | - $titleNames = array_keys($this->titles); |
|
| 448 | - foreach ($titleNames as $name ) |
|
| 446 | + $html=''; |
|
| 447 | + $titleNames=array_keys($this->titles); |
|
| 448 | + foreach ($titleNames as $name) |
|
| 449 | 449 | { |
| 450 | - $html .= '<td>'; |
|
| 451 | - $html .= $value->$name; |
|
| 452 | - $html .= "</td>\n"; |
|
| 450 | + $html.='<td>'; |
|
| 451 | + $html.=$value->$name; |
|
| 452 | + $html.="</td>\n"; |
|
| 453 | 453 | } |
| 454 | 454 | return $html; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | 457 | public function renderTable(array $values) |
| 458 | 458 | { |
| 459 | - $html = '<tbody id="obj_table_body">'; |
|
| 460 | - foreach($values as $value) |
|
| 459 | + $html='<tbody id="obj_table_body">'; |
|
| 460 | + foreach ($values as $value) |
|
| 461 | 461 | { |
| 462 | - $html .= $this->groupingNextLine($value); |
|
| 462 | + $html.=$this->groupingNextLine($value); |
|
| 463 | 463 | |
| 464 | - $html .= "<tr>\n"; |
|
| 465 | - $html .= $this->renderLine($value); |
|
| 466 | - $html .= "</tr>\n"; |
|
| 464 | + $html.="<tr>\n"; |
|
| 465 | + $html.=$this->renderLine($value); |
|
| 466 | + $html.="</tr>\n"; |
|
| 467 | 467 | } |
| 468 | - $html .= '</tbody>'; |
|
| 468 | + $html.='</tbody>'; |
|
| 469 | 469 | return $html; |
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | public function render() |
| 473 | 473 | { |
| 474 | - $html = ''; |
|
| 474 | + $html=''; |
|
| 475 | 475 | |
| 476 | 476 | |
| 477 | - $values = $this->fullQuery(); |
|
| 477 | + $values=$this->fullQuery(); |
|
| 478 | 478 | $this->initGrouping(); |
| 479 | 479 | |
| 480 | 480 | $html.="<table class='simple common-table table-row-selectable'>\n"; |
| 481 | 481 | |
| 482 | - $html .= $this->renderTitles(); |
|
| 483 | - $html .= $this->renderTable($values); |
|
| 484 | - $html .= '</table>'; |
|
| 482 | + $html.=$this->renderTitles(); |
|
| 483 | + $html.=$this->renderTable($values); |
|
| 484 | + $html.='</table>'; |
|
| 485 | 485 | |
| 486 | 486 | |
| 487 | 487 | return $html; |
@@ -18,27 +18,27 @@ discard block |
||
| 18 | 18 | 'handler_categories' => '0:Not categorized' // handlers categories : <index>:<name>!<index>:<name> .... |
| 19 | 19 | ); |
| 20 | 20 | // get default values for dbconfig |
| 21 | - public function getDBConfigDefaults() { return $this->DBConfigDefaults;} |
|
| 21 | + public function getDBConfigDefaults() { return $this->DBConfigDefaults; } |
|
| 22 | 22 | /** Minimum DB version |
| 23 | 23 | * @return number |
| 24 | 24 | */ |
| 25 | - static public function getDbMinVersion() { return 2;} |
|
| 25 | + static public function getDbMinVersion() { return 2; } |
|
| 26 | 26 | /** Current DB version |
| 27 | 27 | * @return number |
| 28 | 28 | */ |
| 29 | - static public function getDbCurVersion() { return 2;} |
|
| 29 | + static public function getDbCurVersion() { return 2; } |
|
| 30 | 30 | |
| 31 | 31 | /************ Module configuration **********************/ |
| 32 | 32 | // Module base path |
| 33 | 33 | static public function urlPath() { return 'trapdirector'; } |
| 34 | - static public function getapiUserPermissions() { return array("status", "objects/query/Host", "objects/query/Service" , "actions/process-check-result"); } //< api user permissions required |
|
| 34 | + static public function getapiUserPermissions() { return array("status", "objects/query/Host", "objects/query/Service", "actions/process-check-result"); } //< api user permissions required |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | /*********** Log configuration *************************/ |
| 38 | 38 | protected $logLevels=array(0=>'No output', 1=>'critical', 2=>'warning', 3=>'trace', 4=>'ALL'); |
| 39 | - public function getlogLevels() { return $this->logLevels;} |
|
| 40 | - protected $logDestinations=array('syslog'=>'syslog','file'=>'file','display'=>'display'); |
|
| 41 | - public function getLogDestinations() { return $this->logDestinations;} |
|
| 39 | + public function getlogLevels() { return $this->logLevels; } |
|
| 40 | + protected $logDestinations=array('syslog'=>'syslog', 'file'=>'file', 'display'=>'display'); |
|
| 41 | + public function getLogDestinations() { return $this->logDestinations; } |
|
| 42 | 42 | |
| 43 | 43 | function __construct($prefix) |
| 44 | 44 | { |
@@ -49,29 +49,29 @@ discard block |
||
| 49 | 49 | // DB table name of trap received list : prefix 't' |
| 50 | 50 | public function getTrapTableName() |
| 51 | 51 | { |
| 52 | - return array('t' => $this->table_prefix . 'received'); |
|
| 52 | + return array('t' => $this->table_prefix.'received'); |
|
| 53 | 53 | } |
| 54 | 54 | // DB table name of trap data list : prefix 'd' |
| 55 | 55 | public function getTrapDataTableName() |
| 56 | 56 | { |
| 57 | - return array('d' => $this->table_prefix . 'received_data'); |
|
| 57 | + return array('d' => $this->table_prefix.'received_data'); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // DB table name of rules : prefix 'r' |
| 61 | 61 | public function getTrapRuleName() |
| 62 | 62 | { |
| 63 | - return array('r' => $this->table_prefix . 'rules'); |
|
| 63 | + return array('r' => $this->table_prefix.'rules'); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // DB table name of db config : prefix 'c' |
| 67 | 67 | public function getDbConfigTableName() |
| 68 | 68 | { |
| 69 | - return array('c' => $this->table_prefix . 'db_config'); |
|
| 69 | + return array('c' => $this->table_prefix.'db_config'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Mib cache tables |
| 73 | - public function getMIBCacheTableName() { return $this->table_prefix . 'mib_cache'; } |
|
| 74 | - public function getMIBCacheTableTrapObjName() { return $this->table_prefix . 'mib_cache_trap_object'; } |
|
| 73 | + public function getMIBCacheTableName() { return $this->table_prefix.'mib_cache'; } |
|
| 74 | + public function getMIBCacheTableTrapObjName() { return $this->table_prefix.'mib_cache_trap_object'; } |
|
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | /****************** Database queries *******************/ |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | public function getHandlerListDisplayColumns() |
| 153 | 153 | { |
| 154 | 154 | return array( |
| 155 | - 'host_name' => 'r.host_name',//'UNIX_TIMESTAMP(t.date_received)', |
|
| 155 | + 'host_name' => 'r.host_name', //'UNIX_TIMESTAMP(t.date_received)', |
|
| 156 | 156 | 'host_group_name'=> 'r.host_group_name', |
| 157 | 157 | 'source_ip' => "CASE WHEN r.ip4 IS NULL THEN r.ip6 ELSE r.ip4 END", |
| 158 | 158 | 'trap_oid' => 'r.trap_oid', |
@@ -224,32 +224,32 @@ discard block |
||
| 224 | 224 | public function trapDetailQuery() |
| 225 | 225 | { |
| 226 | 226 | return array( |
| 227 | - 'timestamp' => array('Date','UNIX_TIMESTAMP(t.date_received)'), |
|
| 228 | - 'source_ip' => array('Source IP','t.source_ip'), |
|
| 229 | - 'source_name' => array('Source name','t.source_name'), |
|
| 230 | - 'source_port' => array('Source port','t.source_port'), |
|
| 231 | - 'destination_ip' => array('Destination IP','t.destination_ip'), |
|
| 232 | - 'destination_port' => array('Destination port','t.destination_port'), |
|
| 233 | - 'trap_oid' => array('Numeric OID','t.trap_oid'), |
|
| 234 | - 'trap_name' => array('Trap name','t.trap_name'), |
|
| 235 | - 'trap_name_mib' => array('Trap MIB','t.trap_name_mib'), |
|
| 236 | - 'status' => array('Processing status','t.status'), |
|
| 237 | - 'status_detail' => array('Status details','t.status_detail'), |
|
| 238 | - 'process_time' => array('Trap processing time','t.process_time'), |
|
| 227 | + 'timestamp' => array('Date', 'UNIX_TIMESTAMP(t.date_received)'), |
|
| 228 | + 'source_ip' => array('Source IP', 't.source_ip'), |
|
| 229 | + 'source_name' => array('Source name', 't.source_name'), |
|
| 230 | + 'source_port' => array('Source port', 't.source_port'), |
|
| 231 | + 'destination_ip' => array('Destination IP', 't.destination_ip'), |
|
| 232 | + 'destination_port' => array('Destination port', 't.destination_port'), |
|
| 233 | + 'trap_oid' => array('Numeric OID', 't.trap_oid'), |
|
| 234 | + 'trap_name' => array('Trap name', 't.trap_name'), |
|
| 235 | + 'trap_name_mib' => array('Trap MIB', 't.trap_name_mib'), |
|
| 236 | + 'status' => array('Processing status', 't.status'), |
|
| 237 | + 'status_detail' => array('Status details', 't.status_detail'), |
|
| 238 | + 'process_time' => array('Trap processing time', 't.process_time'), |
|
| 239 | 239 | ); |
| 240 | 240 | } |
| 241 | 241 | // Trap detail : additional data (<key> => <title> <sql select>) |
| 242 | 242 | public function trapDataDetailQuery() |
| 243 | 243 | { |
| 244 | 244 | return array( |
| 245 | - 'oid' => array('Numeric OID','d.oid'), |
|
| 246 | - 'oid_name' => array('Text OID','d.oid_name'), |
|
| 247 | - 'oid_name_mib' => array('MIB','d.oid_name_mib'), |
|
| 248 | - 'value' => array('Value','d.value'), |
|
| 245 | + 'oid' => array('Numeric OID', 'd.oid'), |
|
| 246 | + 'oid_name' => array('Text OID', 'd.oid_name'), |
|
| 247 | + 'oid_name_mib' => array('MIB', 'd.oid_name_mib'), |
|
| 248 | + 'value' => array('Value', 'd.value'), |
|
| 249 | 249 | ); |
| 250 | 250 | } |
| 251 | 251 | // foreign key of trap data table |
| 252 | - public function trapDataFK() { return 'trap_id';} |
|
| 252 | + public function trapDataFK() { return 'trap_id'; } |
|
| 253 | 253 | |
| 254 | 254 | // Max items in a list OBSOLETE TODO : remove after all tables moved to trapdirectorTable |
| 255 | 255 | public function itemListDisplay() { return 25; } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | /** @var UIDatabase $UIDatabase */ |
| 43 | 43 | protected $UIDatabase; |
| 44 | 44 | /** @var Icinga2Api $IcingaAPI */ |
| 45 | - protected $icingaAPI = NULL; |
|
| 45 | + protected $icingaAPI=NULL; |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $this->redirectNow('trapdirector/settings?message=No database prefix'); |
| 60 | 60 | } |
| 61 | - $this->moduleConfig = new TrapModuleConfig($db_prefix); |
|
| 61 | + $this->moduleConfig=new TrapModuleConfig($db_prefix); |
|
| 62 | 62 | } |
| 63 | 63 | return $this->moduleConfig; |
| 64 | 64 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function getTrapListTable() { |
| 71 | 71 | if ($this->trapTableList == Null) { |
| 72 | - $this->trapTableList = new TrapTableList(); |
|
| 72 | + $this->trapTableList=new TrapTableList(); |
|
| 73 | 73 | $this->trapTableList->setConfig($this->getModuleConfig()); |
| 74 | 74 | } |
| 75 | 75 | return $this->trapTableList; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | if ($this->trapTableHostList == Null) |
| 84 | 84 | { |
| 85 | - $this->trapTableHostList = new TrapTableHostList(); |
|
| 85 | + $this->trapTableHostList=new TrapTableHostList(); |
|
| 86 | 86 | $this->trapTableHostList->setConfig($this->getModuleConfig()); |
| 87 | 87 | } |
| 88 | 88 | return $this->trapTableHostList; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | if ($this->handlerTableList == Null) |
| 97 | 97 | { |
| 98 | - $this->handlerTableList = new HandlerTableList(); |
|
| 98 | + $this->handlerTableList=new HandlerTableList(); |
|
| 99 | 99 | $this->handlerTableList->setConfig($this->getModuleConfig()); |
| 100 | 100 | } |
| 101 | 101 | return $this->handlerTableList; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | { |
| 109 | 109 | if ($this->UIDatabase == Null) |
| 110 | 110 | { |
| 111 | - $this->UIDatabase = new UIDatabase($this); |
|
| 111 | + $this->UIDatabase=new UIDatabase($this); |
|
| 112 | 112 | |
| 113 | 113 | } |
| 114 | 114 | return $this->UIDatabase; |
@@ -122,13 +122,13 @@ discard block |
||
| 122 | 122 | { |
| 123 | 123 | if ($this->icingaAPI === NULL) |
| 124 | 124 | { |
| 125 | - $host = $this->Config()->get('config', 'icingaAPI_host'); |
|
| 126 | - $port = $this->Config()->get('config', 'icingaAPI_port'); |
|
| 127 | - $user = $this->Config()->get('config', 'icingaAPI_user'); |
|
| 128 | - $pass = $this->Config()->get('config', 'icingaAPI_password'); |
|
| 129 | - $this->icingaAPI = new Icinga2API($host,$port); |
|
| 125 | + $host=$this->Config()->get('config', 'icingaAPI_host'); |
|
| 126 | + $port=$this->Config()->get('config', 'icingaAPI_port'); |
|
| 127 | + $user=$this->Config()->get('config', 'icingaAPI_user'); |
|
| 128 | + $pass=$this->Config()->get('config', 'icingaAPI_password'); |
|
| 129 | + $this->icingaAPI=new Icinga2API($host, $port); |
|
| 130 | 130 | $this->icingaAPI->setCredentials($user, $pass); |
| 131 | - list($ret,$message) = $this->icingaAPI->test(NULL); |
|
| 131 | + list($ret, $message)=$this->icingaAPI->test(NULL); |
|
| 132 | 132 | if ($ret === TRUE) |
| 133 | 133 | { |
| 134 | 134 | return $this->getUIDatabase(); |
@@ -139,32 +139,32 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null) |
|
| 142 | + protected function applyPaginationLimits(Paginatable $paginatable, $limit=25, $offset=null) |
|
| 143 | 143 | { |
| 144 | - $limit = $this->params->get('limit', $limit); |
|
| 145 | - $page = $this->params->get('page', $offset); |
|
| 144 | + $limit=$this->params->get('limit', $limit); |
|
| 145 | + $page=$this->params->get('page', $offset); |
|
| 146 | 146 | |
| 147 | 147 | $paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0); |
| 148 | 148 | |
| 149 | 149 | return $paginatable; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - public function displayExitError($source,$message) |
|
| 152 | + public function displayExitError($source, $message) |
|
| 153 | 153 | { // TODO : check better ways to transmit data (with POST ?) |
| 154 | 154 | $this->redirectNow('trapdirector/error?source='.$source.'&message='.$message); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | protected function checkReadPermission() |
| 158 | 158 | { |
| 159 | - if (! $this->Auth()->hasPermission('trapdirector/view')) { |
|
| 160 | - $this->displayExitError('Permissions','No permission fo view content'); |
|
| 159 | + if (!$this->Auth()->hasPermission('trapdirector/view')) { |
|
| 160 | + $this->displayExitError('Permissions', 'No permission fo view content'); |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | protected function checkConfigPermission() |
| 165 | 165 | { |
| 166 | - if (! $this->Auth()->hasPermission('trapdirector/config')) { |
|
| 167 | - $this->displayExitError('Permissions','No permission fo configure'); |
|
| 166 | + if (!$this->Auth()->hasPermission('trapdirector/config')) { |
|
| 167 | + $this->displayExitError('Permissions', 'No permission fo configure'); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | protected function checkModuleConfigPermission($check=0) |
| 177 | 177 | { |
| 178 | - if (! $this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 178 | + if (!$this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 179 | 179 | if ($check == 0) |
| 180 | 180 | { |
| 181 | - $this->displayExitError('Permissions','No permission fo configure module'); |
|
| 181 | + $this->displayExitError('Permissions', 'No permission fo configure module'); |
|
| 182 | 182 | } |
| 183 | 183 | return false; |
| 184 | 184 | } |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | { // TODO : try/catch here ? or within caller |
| 191 | 191 | if ($this->trapClass == null) |
| 192 | 192 | { |
| 193 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 193 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 194 | 194 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 195 | 195 | //$debug_level=4; |
| 196 | - $this->trapClass = new Trap($icingaweb2_etc); |
|
| 196 | + $this->trapClass=new Trap($icingaweb2_etc); |
|
| 197 | 197 | //$Trap->setLogging($debug_level,'syslog'); |
| 198 | 198 | } |
| 199 | 199 | return $this->trapClass; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | if ($this->MIBData == null) |
| 210 | 210 | { |
| 211 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 211 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 212 | 212 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 213 | 213 | $this->MIBData=new MIBLoader( |
| 214 | 214 | $this->Config()->get('config', 'snmptranslate'), |
@@ -228,10 +228,10 @@ discard block |
||
| 228 | 228 | protected function isDirectorInstalled() |
| 229 | 229 | { |
| 230 | 230 | $output=array(); |
| 231 | - exec('icingacli module list',$output); |
|
| 231 | + exec('icingacli module list', $output); |
|
| 232 | 232 | foreach ($output as $line) |
| 233 | 233 | { |
| 234 | - if (preg_match('/^director .*enabled/',$line)) |
|
| 234 | + if (preg_match('/^director .*enabled/', $line)) |
|
| 235 | 235 | { |
| 236 | 236 | return true; |
| 237 | 237 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | public function setitemListDisplay(int $maxRows) |
| 255 | 255 | { |
| 256 | - return $this->getUIDatabase()->setDBConfigValue('max_rows_in_list',$maxRows); |
|
| 256 | + return $this->getUIDatabase()->setDBConfigValue('max_rows_in_list', $maxRows); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -263,13 +263,13 @@ discard block |
||
| 263 | 263 | public function getHandlersCategory() |
| 264 | 264 | { |
| 265 | 265 | //<index>:<name>!<index>:<name> |
| 266 | - $catList = $this->getUIDatabase()->getDBConfigValue('handler_categories'); |
|
| 267 | - $catListArray=explode('!',$catList); |
|
| 266 | + $catList=$this->getUIDatabase()->getDBConfigValue('handler_categories'); |
|
| 267 | + $catListArray=explode('!', $catList); |
|
| 268 | 268 | $retArray=array(); |
| 269 | 269 | foreach ($catListArray as $category) |
| 270 | 270 | { |
| 271 | - $catArray=explode(':',$category); |
|
| 272 | - $retArray[$catArray[0]] = $catArray[1]; |
|
| 271 | + $catArray=explode(':', $category); |
|
| 272 | + $retArray[$catArray[0]]=$catArray[1]; |
|
| 273 | 273 | } |
| 274 | 274 | return $retArray; |
| 275 | 275 | } |
@@ -279,25 +279,25 @@ discard block |
||
| 279 | 279 | $catString=''; |
| 280 | 280 | foreach ($catArray as $index => $value) |
| 281 | 281 | { |
| 282 | - if ($catString != '' ) $catString .= '!'; |
|
| 283 | - $catString .= $index . ':' . $value; |
|
| 282 | + if ($catString != '') $catString.='!'; |
|
| 283 | + $catString.=$index.':'.$value; |
|
| 284 | 284 | } |
| 285 | 285 | $this->getUIDatabase()->setDBConfigValue('handler_categories', $catString); |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | public function addHandlersCategory(string $catName) |
| 289 | 289 | { |
| 290 | - $catArray = $this->getHandlersCategory(); |
|
| 290 | + $catArray=$this->getHandlersCategory(); |
|
| 291 | 291 | $i=1; |
| 292 | 292 | while (isset($catArray[$i]) && $i < 100) $i++; |
| 293 | 293 | if ($i == 100) throw new ProgrammingError('Category array error'); |
| 294 | - $catArray[$i] = $catName; |
|
| 294 | + $catArray[$i]=$catName; |
|
| 295 | 295 | $this->setHandlerCategory($catArray); |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | public function delHandlersCategory(int $catIndex) |
| 299 | 299 | { |
| 300 | - $catArray = $this->getHandlersCategory(); |
|
| 300 | + $catArray=$this->getHandlersCategory(); |
|
| 301 | 301 | unset($catArray[$catIndex]); |
| 302 | 302 | $this->setHandlerCategory($catArray); |
| 303 | 303 | $this->getUIDatabase()->updateHandlersOnCategoryDelete($catIndex); |
@@ -305,8 +305,8 @@ discard block |
||
| 305 | 305 | |
| 306 | 306 | public function renameHandlersCategory(int $catIndex, string $catName) |
| 307 | 307 | { |
| 308 | - $catArray = $this->getHandlersCategory(); |
|
| 309 | - $catArray[$catIndex] = $catName; |
|
| 308 | + $catArray=$this->getHandlersCategory(); |
|
| 309 | + $catArray[$catIndex]=$catName; |
|
| 310 | 310 | $this->setHandlerCategory($catArray); |
| 311 | 311 | } |
| 312 | 312 | |
@@ -34,18 +34,18 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | // TODO Check for rule consistency |
| 36 | 36 | |
| 37 | - $dbConn = $this->getDbConn(); |
|
| 37 | + $dbConn=$this->getDbConn(); |
|
| 38 | 38 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 39 | 39 | // Add last modified date = creation date and username |
| 40 | - $params['created'] = new Zend_Db_Expr('NOW()'); |
|
| 41 | - $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 42 | - $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 40 | + $params['created']=new Zend_Db_Expr('NOW()'); |
|
| 41 | + $params['modified']=new Zend_Db_Expr('NOW()'); |
|
| 42 | + $params['modifier']=$this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 43 | 43 | |
| 44 | 44 | $query=$dbConn->insert( |
| 45 | 45 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
| 46 | 46 | $params |
| 47 | 47 | ); |
| 48 | - if($query==false) |
|
| 48 | + if ($query == false) |
|
| 49 | 49 | { |
| 50 | 50 | return null; |
| 51 | 51 | } |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | * @param integer $ruleID : rule id in db |
| 58 | 58 | * @return array affected rows |
| 59 | 59 | */ |
| 60 | - public function updateHandlerRule($params,$ruleID) |
|
| 60 | + public function updateHandlerRule($params, $ruleID) |
|
| 61 | 61 | { |
| 62 | 62 | // TODO Check for rule consistency |
| 63 | - $dbConn = $this->getDbConn(); |
|
| 63 | + $dbConn=$this->getDbConn(); |
|
| 64 | 64 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 65 | 65 | // Add last modified date = creation date and username |
| 66 | - $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 67 | - $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 66 | + $params['modified']=new Zend_Db_Expr('NOW()'); |
|
| 67 | + $params['modifier']=$this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
|
| 68 | 68 | |
| 69 | 69 | $numRows=$dbConn->update( |
| 70 | 70 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | public function updateHandlersOnCategoryDelete($catIndex) |
| 84 | 84 | { |
| 85 | 85 | // TODO Check for rule consistency |
| 86 | - $dbConn = $this->getDbConn(); |
|
| 86 | + $dbConn=$this->getDbConn(); |
|
| 87 | 87 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 88 | 88 | |
| 89 | 89 | $numRows=$dbConn->update( |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function deleteRule($ruleID) |
| 101 | 101 | { |
| 102 | - if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id'); } |
|
| 102 | + if (!preg_match('/^[0-9]+$/', $ruleID)) { throw new Exception('Invalid id'); } |
|
| 103 | 103 | |
| 104 | - $dbConn = $this->getDbConn(); |
|
| 104 | + $dbConn=$this->getDbConn(); |
|
| 105 | 105 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 106 | 106 | |
| 107 | 107 | $query=$dbConn->delete( |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | public function lastModification() |
| 120 | 120 | { |
| 121 | - $dbConn = $this->getDbConn(); |
|
| 121 | + $dbConn=$this->getDbConn(); |
|
| 122 | 122 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 123 | 123 | |
| 124 | - $query = $dbConn->select() |
|
| 124 | + $query=$dbConn->select() |
|
| 125 | 125 | ->from( |
| 126 | 126 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
| 127 | 127 | array('lastModified'=>'UNIX_TIMESTAMP(MAX(modified))')); |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | * @param $ipAddr string source IP (v4 or v6) |
| 134 | 134 | * @param $oid string oid |
| 135 | 135 | */ |
| 136 | - public function deleteTrap($ipAddr,$oid) |
|
| 136 | + public function deleteTrap($ipAddr, $oid) |
|
| 137 | 137 | { |
| 138 | 138 | |
| 139 | - $dbConn = $this->getDbConn(); |
|
| 139 | + $dbConn=$this->getDbConn(); |
|
| 140 | 140 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 141 | 141 | $condition=null; |
| 142 | 142 | if ($ipAddr != null) |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | if ($oid != null) |
| 147 | 147 | { |
| 148 | - $condition=($condition===null)?'':$condition.' AND '; |
|
| 148 | + $condition=($condition === null) ? '' : $condition.' AND '; |
|
| 149 | 149 | $condition.="trap_oid='$oid'"; |
| 150 | 150 | } |
| 151 | - if($condition === null) return null; |
|
| 151 | + if ($condition === null) return null; |
|
| 152 | 152 | $query=$dbConn->delete( |
| 153 | 153 | $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
| 154 | 154 | $condition |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | * @param $ipAddr string source IP (v4 or v6) |
| 163 | 163 | * @param $oid string oid |
| 164 | 164 | */ |
| 165 | - public function countTrap($ipAddr,$oid) |
|
| 165 | + public function countTrap($ipAddr, $oid) |
|
| 166 | 166 | { |
| 167 | 167 | |
| 168 | - $dbConn = $this->getDbConn(); |
|
| 168 | + $dbConn=$this->getDbConn(); |
|
| 169 | 169 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 170 | 170 | |
| 171 | 171 | $condition=null; |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | if ($oid != null) |
| 177 | 177 | { |
| 178 | - $condition=($condition===null)?'':$condition.' AND '; |
|
| 178 | + $condition=($condition === null) ? '' : $condition.' AND '; |
|
| 179 | 179 | $condition.="trap_oid='$oid'"; |
| 180 | 180 | } |
| 181 | - if($condition === null) return 0; |
|
| 181 | + if ($condition === null) return 0; |
|
| 182 | 182 | $query=$dbConn->select() |
| 183 | 183 | ->from( |
| 184 | 184 | $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
@@ -194,28 +194,28 @@ discard block |
||
| 194 | 194 | public function getDBConfigValue($element) |
| 195 | 195 | { |
| 196 | 196 | |
| 197 | - $dbConn = $this->getDbConn(); |
|
| 197 | + $dbConn=$this->getDbConn(); |
|
| 198 | 198 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 199 | 199 | |
| 200 | 200 | $query=$dbConn->select() |
| 201 | 201 | ->from( |
| 202 | 202 | $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
| 203 | 203 | array('value'=>'value')) |
| 204 | - ->where('name=?',$element); |
|
| 204 | + ->where('name=?', $element); |
|
| 205 | 205 | $returnRow=$dbConn->fetchRow($query); |
| 206 | - if ($returnRow==null) // value does not exists |
|
| 206 | + if ($returnRow == null) // value does not exists |
|
| 207 | 207 | { |
| 208 | 208 | $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
| 209 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 209 | + if (!isset($default[$element])) return null; // no default and not value |
|
| 210 | 210 | |
| 211 | - $this->addDBConfigValue($element,$default[$element]); |
|
| 211 | + $this->addDBConfigValue($element, $default[$element]); |
|
| 212 | 212 | return $default[$element]; |
| 213 | 213 | } |
| 214 | 214 | if ($returnRow->value == null) // value id empty |
| 215 | 215 | { |
| 216 | 216 | $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
| 217 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 218 | - $this->setDBConfigValue($element,$default[$element]); |
|
| 217 | + if (!isset($default[$element])) return null; // no default and not value |
|
| 218 | + $this->setDBConfigValue($element, $default[$element]); |
|
| 219 | 219 | return $default[$element]; |
| 220 | 220 | } |
| 221 | 221 | return $returnRow->value; |
@@ -226,10 +226,10 @@ discard block |
||
| 226 | 226 | * @param string $value : value |
| 227 | 227 | */ |
| 228 | 228 | |
| 229 | - public function addDBConfigValue($element,$value) |
|
| 229 | + public function addDBConfigValue($element, $value) |
|
| 230 | 230 | { |
| 231 | 231 | |
| 232 | - $dbConn = $this->getDbConn(); |
|
| 232 | + $dbConn=$this->getDbConn(); |
|
| 233 | 233 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 234 | 234 | |
| 235 | 235 | $query=$dbConn->insert( |
@@ -246,10 +246,10 @@ discard block |
||
| 246 | 246 | * @param string $element : name of config element |
| 247 | 247 | * @param string $value : value |
| 248 | 248 | */ |
| 249 | - public function setDBConfigValue($element,$value) |
|
| 249 | + public function setDBConfigValue($element, $value) |
|
| 250 | 250 | { |
| 251 | 251 | |
| 252 | - $dbConn = $this->getDbConn(); |
|
| 252 | + $dbConn=$this->getDbConn(); |
|
| 253 | 253 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 254 | 254 | |
| 255 | 255 | $query=$dbConn->update( |
@@ -21,19 +21,19 @@ discard block |
||
| 21 | 21 | /************ Trapdb ***********/ |
| 22 | 22 | try |
| 23 | 23 | { |
| 24 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 24 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 25 | 25 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 26 | - $query = $dbConn->select()->from( |
|
| 26 | + $query=$dbConn->select()->from( |
|
| 27 | 27 | $this->getModuleConfig()->getTrapTableName(), |
| 28 | 28 | array('COUNT(*)') |
| 29 | 29 | ); |
| 30 | 30 | $this->view->trap_count=$dbConn->fetchOne($query); |
| 31 | - $query = $dbConn->select()->from( |
|
| 31 | + $query=$dbConn->select()->from( |
|
| 32 | 32 | $this->getModuleConfig()->getTrapDataTableName(), |
| 33 | 33 | array('COUNT(*)') |
| 34 | 34 | ); |
| 35 | 35 | $this->view->trap_object_count=$dbConn->fetchOne($query); |
| 36 | - $query = $dbConn->select()->from( |
|
| 36 | + $query=$dbConn->select()->from( |
|
| 37 | 37 | $this->getModuleConfig()->getTrapRuleName(), |
| 38 | 38 | array('COUNT(*)') |
| 39 | 39 | ); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | catch (Exception $e) |
| 46 | 46 | { |
| 47 | - $this->displayExitError('status',$e->getMessage()); |
|
| 47 | + $this->displayExitError('status', $e->getMessage()); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /*************** Log destination *******************/ |
@@ -59,20 +59,20 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | catch (Exception $e) |
| 61 | 61 | { |
| 62 | - $this->displayExitError('status',$e->getMessage()); |
|
| 62 | + $this->displayExitError('status', $e->getMessage()); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /*************** SNMP configuration ****************/ |
| 66 | 66 | try |
| 67 | 67 | { |
| 68 | - $this->view->useSnmpTrapAddess= ( $this->getUIDatabase()->getDBConfigValue('use_SnmpTrapAddess') == 1 ) ? TRUE : FALSE; |
|
| 68 | + $this->view->useSnmpTrapAddess=($this->getUIDatabase()->getDBConfigValue('use_SnmpTrapAddess') == 1) ? TRUE : FALSE; |
|
| 69 | 69 | $this->view->SnmpTrapAddressOID=$this->getUIDatabase()->getDBConfigValue('SnmpTrapAddess_oid'); |
| 70 | - $this->view->SnmpTrapAddressOIDDefault = ($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid'] ) ? TRUE : FALSE; |
|
| 70 | + $this->view->SnmpTrapAddressOIDDefault=($this->view->SnmpTrapAddressOID == $this->getModuleConfig()->getDBConfigDefaults()['SnmpTrapAddess_oid']) ? TRUE : FALSE; |
|
| 71 | 71 | |
| 72 | 72 | } |
| 73 | 73 | catch (Exception $e) |
| 74 | 74 | { |
| 75 | - $this->displayExitError('status',$e->getMessage()); |
|
| 75 | + $this->displayExitError('status', $e->getMessage()); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | if ($action == 'update_mib_db') |
| 99 | 99 | { // Do the update in background |
| 100 | 100 | $return=exec('icingacli trapdirector mib update --pid /tmp/trapdirector_update.pid'); |
| 101 | - if (preg_match('/OK/',$return)) |
|
| 101 | + if (preg_match('/OK/', $return)) |
|
| 102 | 102 | { |
| 103 | 103 | $this->_helper->json(array('status'=>'OK')); |
| 104 | 104 | } |
@@ -107,32 +107,32 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | if ($action == 'check_update') |
| 109 | 109 | { |
| 110 | - $file=@fopen('/tmp/trapdirector_update.pid','r'); |
|
| 110 | + $file=@fopen('/tmp/trapdirector_update.pid', 'r'); |
|
| 111 | 111 | if ($file == false) |
| 112 | 112 | { // process is dead |
| 113 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file')); |
|
| 113 | + $this->_helper->json(array('status'=>'tu quoque fili', 'err'=>'Cannot open file')); |
|
| 114 | 114 | return; |
| 115 | 115 | } |
| 116 | 116 | $pid=fgets($file); |
| 117 | 117 | $output=array(); |
| 118 | 118 | $retVal=0; |
| 119 | - exec('ps '.$pid,$output,$retVal); |
|
| 119 | + exec('ps '.$pid, $output, $retVal); |
|
| 120 | 120 | if ($retVal == 0) |
| 121 | 121 | { // process is alive |
| 122 | 122 | $this->_helper->json(array('status'=>'Alive and kicking')); |
| 123 | 123 | } |
| 124 | 124 | else |
| 125 | 125 | { // process is dead |
| 126 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
|
| 126 | + $this->_helper->json(array('status'=>'tu quoque fili', 'err'=>'no proc'.$pid)); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | - $this->_helper->json(array('status'=>'ERR : no '.$action.' action possible' )); |
|
| 129 | + $this->_helper->json(array('status'=>'ERR : no '.$action.' action possible')); |
|
| 130 | 130 | } |
| 131 | 131 | /** Check for mib file UPLOAD */ |
| 132 | 132 | if (isset($_FILES['mibfile'])) |
| 133 | 133 | { |
| 134 | - $name=filter_var($_FILES['mibfile']['name'],FILTER_SANITIZE_STRING); |
|
| 135 | - $DirConf=explode(':',$this->Config()->get('config', 'snmptranslate_dirs')); |
|
| 134 | + $name=filter_var($_FILES['mibfile']['name'], FILTER_SANITIZE_STRING); |
|
| 135 | + $DirConf=explode(':', $this->Config()->get('config', 'snmptranslate_dirs')); |
|
| 136 | 136 | $destDir=array_shift($DirConf); |
| 137 | 137 | if (!is_dir($destDir)) |
| 138 | 138 | { |
@@ -146,9 +146,9 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | else |
| 148 | 148 | { |
| 149 | - $destination = $destDir .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
|
| 150 | - $sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'],FILTER_SANITIZE_STRING); |
|
| 151 | - if (move_uploaded_file($sourceTmpNam,$destination)===false) |
|
| 149 | + $destination=$destDir.'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
|
| 150 | + $sourceTmpNam=filter_var($_FILES['mibfile']['tmp_name'], FILTER_SANITIZE_STRING); |
|
| 151 | + if (move_uploaded_file($sourceTmpNam, $destination) === false) |
|
| 152 | 152 | { |
| 153 | 153 | $this->view->uploadStatus="ERROR, file $destination not loaded. Check file and path name or selinux violations"; |
| 154 | 154 | } |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // snmptranslate tests |
| 167 | - $snmptranslate = $this->Config()->get('config', 'snmptranslate'); |
|
| 167 | + $snmptranslate=$this->Config()->get('config', 'snmptranslate'); |
|
| 168 | 168 | $this->view->snmptranslate_bin=$snmptranslate; |
| 169 | 169 | $this->view->snmptranslate_state='warn'; |
| 170 | - if (is_executable ( $snmptranslate )) |
|
| 170 | + if (is_executable($snmptranslate)) |
|
| 171 | 171 | { |
| 172 | - $translate=exec($snmptranslate . ' 1'); |
|
| 173 | - if (preg_match('/iso/',$translate)) |
|
| 172 | + $translate=exec($snmptranslate.' 1'); |
|
| 173 | + if (preg_match('/iso/', $translate)) |
|
| 174 | 174 | { |
| 175 | 175 | $this->view->snmptranslate='works fine'; |
| 176 | 176 | $this->view->snmptranslate_state='ok'; |
@@ -188,46 +188,46 @@ discard block |
||
| 188 | 188 | // mib database |
| 189 | 189 | |
| 190 | 190 | $this->view->mibDbCount=$this->getMIB()->countObjects(); |
| 191 | - $this->view->mibDbCountTrap=$this->getMIB()->countObjects(null,21); |
|
| 191 | + $this->view->mibDbCountTrap=$this->getMIB()->countObjects(null, 21); |
|
| 192 | 192 | |
| 193 | 193 | // mib dirs |
| 194 | 194 | $DirConf=$this->Config()->get('config', 'snmptranslate_dirs'); |
| 195 | - $dirArray=explode(':',$DirConf); |
|
| 195 | + $dirArray=explode(':', $DirConf); |
|
| 196 | 196 | |
| 197 | 197 | // Get base directories from net-snmp-config |
| 198 | 198 | $output=$matches=array(); |
| 199 | 199 | $retVal=0; |
| 200 | - $sysDirs=exec('net-snmp-config --default-mibdirs',$output,$retVal); |
|
| 201 | - if ($retVal==0) |
|
| 200 | + $sysDirs=exec('net-snmp-config --default-mibdirs', $output, $retVal); |
|
| 201 | + if ($retVal == 0) |
|
| 202 | 202 | { |
| 203 | - $dirArray=array_merge($dirArray,explode(':',$sysDirs)); |
|
| 203 | + $dirArray=array_merge($dirArray, explode(':', $sysDirs)); |
|
| 204 | 204 | } |
| 205 | 205 | else |
| 206 | 206 | { |
| 207 | - $translateOut=exec($this->Config()->get('config', 'snmptranslate') . ' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
|
| 208 | - if (preg_match('/MIBDIRS.*\'([^\']+)\'/',$translateOut,$matches)) |
|
| 207 | + $translateOut=exec($this->Config()->get('config', 'snmptranslate').' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
|
| 208 | + if (preg_match('/MIBDIRS.*\'([^\']+)\'/', $translateOut, $matches)) |
|
| 209 | 209 | { |
| 210 | - $dirArray=array_merge($dirArray,explode(':',$matches[1])); |
|
| 210 | + $dirArray=array_merge($dirArray, explode(':', $matches[1])); |
|
| 211 | 211 | } |
| 212 | 212 | else |
| 213 | 213 | { |
| 214 | - array_push($dirArray,'Install net-snmp-config to see system directories'); |
|
| 214 | + array_push($dirArray, 'Install net-snmp-config to see system directories'); |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $this->view->dirArray=$dirArray; |
| 219 | 219 | |
| 220 | 220 | $output=null; |
| 221 | - foreach (explode(':',$DirConf) as $mibdir) |
|
| 221 | + foreach (explode(':', $DirConf) as $mibdir) |
|
| 222 | 222 | { |
| 223 | - exec('ls '.$mibdir.' | grep -v traplist.txt',$output); |
|
| 223 | + exec('ls '.$mibdir.' | grep -v traplist.txt', $output); |
|
| 224 | 224 | } |
| 225 | 225 | //$i=0;$listFiles='';while (isset($output[$i])) $listFiles.=$output[$i++]; |
| 226 | 226 | //$this->view->fileList=explode(' ',$listFiles); |
| 227 | 227 | $this->view->fileList=$output; |
| 228 | 228 | |
| 229 | 229 | // Zend form |
| 230 | - $this->view->form= new UploadForm(); |
|
| 230 | + $this->view->form=new UploadForm(); |
|
| 231 | 231 | //$this->view->form= new Form('upload-form'); |
| 232 | 232 | |
| 233 | 233 | |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | $this->view->setOKMsg=''; |
| 243 | 243 | |
| 244 | 244 | //max_rows=25&row_update=update |
| 245 | - if ( $this->getRequest()->getParam('max_rows',NULL) !== NULL ) |
|
| 245 | + if ($this->getRequest()->getParam('max_rows', NULL) !== NULL) |
|
| 246 | 246 | { |
| 247 | - $maxRows = $this->getRequest()->getParam('max_rows'); |
|
| 247 | + $maxRows=$this->getRequest()->getParam('max_rows'); |
|
| 248 | 248 | if (!preg_match('/^[0-9]+$/', $maxRows) || $maxRows < 1) |
| 249 | 249 | { |
| 250 | 250 | $this->view->setError='Max rows must be a number'; |
@@ -252,21 +252,21 @@ discard block |
||
| 252 | 252 | else |
| 253 | 253 | { |
| 254 | 254 | $this->setitemListDisplay($maxRows); |
| 255 | - $this->view->setOKMsg='Set max rows to ' . $maxRows; |
|
| 255 | + $this->view->setOKMsg='Set max rows to '.$maxRows; |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( $this->getRequest()->getParam('add_category',NULL) !== NULL ) |
|
| 259 | + if ($this->getRequest()->getParam('add_category', NULL) !== NULL) |
|
| 260 | 260 | { |
| 261 | - $addCat = $this->getRequest()->getParam('add_category'); |
|
| 261 | + $addCat=$this->getRequest()->getParam('add_category'); |
|
| 262 | 262 | $this->addHandlersCategory($addCat); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if ( $this->getRequest()->getPost('type',NULL) !== NULL ) |
|
| 265 | + if ($this->getRequest()->getPost('type', NULL) !== NULL) |
|
| 266 | 266 | { |
| 267 | - $type = $this->getRequest()->getPost('type',NULL); |
|
| 268 | - $index = $this->getRequest()->getPost('index',NULL); |
|
| 269 | - $newname = $this->getRequest()->getPost('newname',NULL); |
|
| 267 | + $type=$this->getRequest()->getPost('type', NULL); |
|
| 268 | + $index=$this->getRequest()->getPost('index', NULL); |
|
| 269 | + $newname=$this->getRequest()->getPost('newname', NULL); |
|
| 270 | 270 | |
| 271 | 271 | if (!preg_match('/^[0-9]+$/', $index) || $index < 1) |
| 272 | 272 | $this->_helper->json(array('status'=>'Bad index')); |
@@ -290,9 +290,9 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - $this->view->maxRows = $this->itemListDisplay(); |
|
| 293 | + $this->view->maxRows=$this->itemListDisplay(); |
|
| 294 | 294 | |
| 295 | - $this->view->categories = $this->getHandlersCategory(); |
|
| 295 | + $this->view->categories=$this->getHandlersCategory(); |
|
| 296 | 296 | |
| 297 | 297 | |
| 298 | 298 | |
@@ -316,18 +316,18 @@ discard block |
||
| 316 | 316 | $this->view->templateForm_output=''; |
| 317 | 317 | if (isset($postData['template_name']) && isset($postData['template_revert_time'])) |
| 318 | 318 | { |
| 319 | - $template_create = 'icingacli director service create --json \'{ "check_command": "dummy", '; |
|
| 320 | - $template_create .= '"check_interval": "' .$postData['template_revert_time']. '", "check_timeout": "20", "disabled": false, "enable_active_checks": true, "enable_event_handler": true, "enable_notifications": true, "enable_passive_checks": true, "enable_perfdata": true, "max_check_attempts": "1", '; |
|
| 321 | - $template_create .= '"object_name": "'.$postData['template_name'].'", "object_type": "template", "retry_interval": "'.$postData['template_revert_time'].'"}\''; |
|
| 319 | + $template_create='icingacli director service create --json \'{ "check_command": "dummy", '; |
|
| 320 | + $template_create.='"check_interval": "'.$postData['template_revert_time'].'", "check_timeout": "20", "disabled": false, "enable_active_checks": true, "enable_event_handler": true, "enable_notifications": true, "enable_passive_checks": true, "enable_perfdata": true, "max_check_attempts": "1", '; |
|
| 321 | + $template_create.='"object_name": "'.$postData['template_name'].'", "object_type": "template", "retry_interval": "'.$postData['template_revert_time'].'"}\''; |
|
| 322 | 322 | $output=array(); |
| 323 | 323 | $ret_code=0; |
| 324 | - exec($template_create,$output,$ret_code); |
|
| 324 | + exec($template_create, $output, $ret_code); |
|
| 325 | 325 | if ($ret_code != 0) |
| 326 | 326 | { |
| 327 | - $this->displayExitError("Status -> Services","Error creating template : ".$output[0].'<br>Command was : '.$template_create); |
|
| 327 | + $this->displayExitError("Status -> Services", "Error creating template : ".$output[0].'<br>Command was : '.$template_create); |
|
| 328 | 328 | } |
| 329 | - exec('icingacli director config deploy',$output,$ret_code); |
|
| 330 | - $this->view->templateForm_output='Template '.$postData['template_name']. ' created'; |
|
| 329 | + exec('icingacli director config deploy', $output, $ret_code); |
|
| 330 | + $this->view->templateForm_output='Template '.$postData['template_name'].' created'; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // template creation form |
@@ -343,15 +343,15 @@ discard block |
||
| 343 | 343 | { |
| 344 | 344 | $this->prepareTabs()->activate('plugins'); |
| 345 | 345 | |
| 346 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 346 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 347 | 347 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 348 | - $Trap = new Trap($icingaweb2_etc,4); |
|
| 348 | + $Trap=new Trap($icingaweb2_etc, 4); |
|
| 349 | 349 | |
| 350 | - $this->view->pluginLoaded = htmlentities($Trap->pluginClass->registerAllPlugins(false)); |
|
| 350 | + $this->view->pluginLoaded=htmlentities($Trap->pluginClass->registerAllPlugins(false)); |
|
| 351 | 351 | |
| 352 | - $enabledPlugins = $Trap->pluginClass->getEnabledPlugins(); |
|
| 352 | + $enabledPlugins=$Trap->pluginClass->getEnabledPlugins(); |
|
| 353 | 353 | |
| 354 | - $pluginList = $Trap->pluginClass->pluginList(); |
|
| 354 | + $pluginList=$Trap->pluginClass->pluginList(); |
|
| 355 | 355 | |
| 356 | 356 | // Plugin list and fill function name list |
| 357 | 357 | $functionList=array(); |
@@ -359,16 +359,16 @@ discard block |
||
| 359 | 359 | foreach ($pluginList as $plugin) |
| 360 | 360 | { |
| 361 | 361 | $pluginDetails=$Trap->pluginClass->pluginDetails($plugin); |
| 362 | - $pluginDetails->enabled = (in_array($plugin, $enabledPlugins)) ? true : false; |
|
| 363 | - $pluginDetails->catchAllTraps = ($pluginDetails->catchAllTraps === true )? 'Yes' : 'No'; |
|
| 364 | - $pluginDetails->processTraps = ($pluginDetails->processTraps === true )? 'Yes' : 'No'; |
|
| 365 | - $pluginDetails->description = htmlentities($pluginDetails->description); |
|
| 366 | - $pluginDetails->description = preg_replace('/\n/','<br>',$pluginDetails->description); |
|
| 362 | + $pluginDetails->enabled=(in_array($plugin, $enabledPlugins)) ? true : false; |
|
| 363 | + $pluginDetails->catchAllTraps=($pluginDetails->catchAllTraps === true) ? 'Yes' : 'No'; |
|
| 364 | + $pluginDetails->processTraps=($pluginDetails->processTraps === true) ? 'Yes' : 'No'; |
|
| 365 | + $pluginDetails->description=htmlentities($pluginDetails->description); |
|
| 366 | + $pluginDetails->description=preg_replace('/\n/', '<br>', $pluginDetails->description); |
|
| 367 | 367 | array_push($this->view->pluginArray, $pluginDetails); |
| 368 | 368 | // Get functions for function details |
| 369 | 369 | foreach ($pluginDetails->funcArray as $function) |
| 370 | 370 | { |
| 371 | - array_push($functionList,$function); |
|
| 371 | + array_push($functionList, $function); |
|
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | |
@@ -376,10 +376,10 @@ discard block |
||
| 376 | 376 | $this->view->functionList=array(); |
| 377 | 377 | foreach ($functionList as $function) |
| 378 | 378 | { |
| 379 | - $functionDetail = $Trap->pluginClass->getFunctionDetails($function); |
|
| 380 | - $functionDetail->params = htmlentities($functionDetail->params); |
|
| 381 | - $functionDetail->description = htmlentities($functionDetail->description); |
|
| 382 | - $functionDetail->description = preg_replace('/\n/','<br>',$functionDetail->description); |
|
| 379 | + $functionDetail=$Trap->pluginClass->getFunctionDetails($function); |
|
| 380 | + $functionDetail->params=htmlentities($functionDetail->params); |
|
| 381 | + $functionDetail->description=htmlentities($functionDetail->description); |
|
| 382 | + $functionDetail->description=preg_replace('/\n/', '<br>', $functionDetail->description); |
|
| 383 | 383 | array_push($this->view->functionList, $functionDetail); |
| 384 | 384 | } |
| 385 | 385 | |
@@ -389,19 +389,19 @@ discard block |
||
| 389 | 389 | { |
| 390 | 390 | return $this->getTabs()->add('status', array( |
| 391 | 391 | 'label' => $this->translate('Status'), |
| 392 | - 'url' => $this->getModuleConfig()->urlPath() . '/status') |
|
| 392 | + 'url' => $this->getModuleConfig()->urlPath().'/status') |
|
| 393 | 393 | )->add('mib', array( |
| 394 | 394 | 'label' => $this->translate('MIB Management'), |
| 395 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/mib') |
|
| 395 | + 'url' => $this->getModuleConfig()->urlPath().'/status/mib') |
|
| 396 | 396 | )->add('uimgt', array( |
| 397 | 397 | 'label' => $this->translate('UI Configuration'), |
| 398 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/uimgt') |
|
| 398 | + 'url' => $this->getModuleConfig()->urlPath().'/status/uimgt') |
|
| 399 | 399 | )->add('services', array( |
| 400 | 400 | 'label' => $this->translate('Services management'), |
| 401 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/services') |
|
| 401 | + 'url' => $this->getModuleConfig()->urlPath().'/status/services') |
|
| 402 | 402 | )->add('plugins', array( |
| 403 | 403 | 'label' => $this->translate('Plugins management'), |
| 404 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/plugins') |
|
| 404 | + 'url' => $this->getModuleConfig()->urlPath().'/status/plugins') |
|
| 405 | 405 | ); |
| 406 | 406 | } |
| 407 | 407 | } |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | // TODO : see if useless |
| 410 | 410 | class UploadForm extends Form |
| 411 | 411 | { |
| 412 | - public function __construct($options = null) |
|
| 412 | + public function __construct($options=null) |
|
| 413 | 413 | { |
| 414 | 414 | parent::__construct($options); |
| 415 | 415 | $this->addElements2(); |
@@ -418,11 +418,11 @@ discard block |
||
| 418 | 418 | public function addElements2() |
| 419 | 419 | { |
| 420 | 420 | // File Input |
| 421 | - $file = new File('mib-file'); |
|
| 421 | + $file=new File('mib-file'); |
|
| 422 | 422 | $file->setLabel('Mib upload'); |
| 423 | 423 | //->setAttrib('multiple', null); |
| 424 | 424 | $this->addElement($file); |
| 425 | - $button = new Submit("upload",array('ignore'=>false)); |
|
| 426 | - $this->addElement($button);//->setIgnore(false); |
|
| 425 | + $button=new Submit("upload", array('ignore'=>false)); |
|
| 426 | + $this->addElement($button); //->setIgnore(false); |
|
| 427 | 427 | } |
| 428 | 428 | } |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | $this->checkReadPermission(); |
| 25 | 25 | $this->prepareTabs()->activate('status'); |
| 26 | 26 | |
| 27 | - $dbConn = $this->getUIDatabase()->getDb(); |
|
| 27 | + $dbConn=$this->getUIDatabase()->getDb(); |
|
| 28 | 28 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 29 | 29 | |
| 30 | - $handlerTable = new HandlerTable( |
|
| 30 | + $handlerTable=new HandlerTable( |
|
| 31 | 31 | $this->moduleConfig->getTrapRuleName(), |
| 32 | 32 | $this->moduleConfig->getHandlerListTitles(), |
| 33 | 33 | $this->moduleConfig->getHandlerListDisplayColumns(), |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | $handlerTable->setMibloader($this->getMIB()); |
| 42 | 42 | |
| 43 | - $getVars = $this->getRequest()->getParams(); |
|
| 43 | + $getVars=$this->getRequest()->getParams(); |
|
| 44 | 44 | $handlerTable->getParams($getVars); |
| 45 | 45 | |
| 46 | 46 | if ($handlerTable->isOrderSet() == FALSE) |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $this->view->handlerTable = $handlerTable; |
|
| 54 | + $this->view->handlerTable=$handlerTable; |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | 57 | // TODO : Obsolete remove after new table validation. |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | public function testruleAction() |
| 75 | 75 | { |
| 76 | 76 | $this->checkReadPermission(); |
| 77 | - $this->getTabs()->add('get',array( |
|
| 77 | + $this->getTabs()->add('get', array( |
|
| 78 | 78 | 'active' => true, |
| 79 | 79 | 'label' => $this->translate('Test Rule'), |
| 80 | 80 | 'url' => Url::fromRequest() |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | if ($this->params->get('rule') !== null) |
| 85 | 85 | { |
| 86 | - $this->view->rule= $this->params->get('rule'); |
|
| 86 | + $this->view->rule=$this->params->get('rule'); |
|
| 87 | 87 | } |
| 88 | 88 | else |
| 89 | 89 | { |
@@ -142,12 +142,12 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | catch (Exception $e) |
| 144 | 144 | { |
| 145 | - $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage()); |
|
| 145 | + $this->displayExitError('Add handler : get host by IP/Name ', $e->getMessage()); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | |
| 149 | 149 | // if one unique host found -> put id text input |
| 150 | - if (count($hosts)==1) { |
|
| 150 | + if (count($hosts) == 1) { |
|
| 151 | 151 | $this->view->hostname=$hosts[0]->name; |
| 152 | 152 | //$hostid=$hosts[0]->id; |
| 153 | 153 | // Tell JS to get services when page is loaded |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | else |
| 158 | 158 | { |
| 159 | - foreach($hosts as $key=>$val) |
|
| 159 | + foreach ($hosts as $key=>$val) |
|
| 160 | 160 | { |
| 161 | - array_push($this->view->hostlist,$hosts[$key]->name); |
|
| 161 | + array_push($this->view->hostlist, $hosts[$key]->name); |
|
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | 164 | |
@@ -197,18 +197,18 @@ discard block |
||
| 197 | 197 | $currentObjectTypeEnum |
| 198 | 198 | ); |
| 199 | 199 | $oid_index++; |
| 200 | - array_push($this->view->objectList,$currentObject); |
|
| 200 | + array_push($this->view->objectList, $currentObject); |
|
| 201 | 201 | // set currrent object to null in allObjects |
| 202 | 202 | if (isset($allObjects[$val->oid])) |
| 203 | 203 | { |
| 204 | 204 | $allObjects[$val->oid]=null; |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | - if ($allObjects!=null) // in case trap doesn't have objects or is not resolved |
|
| 207 | + if ($allObjects != null) // in case trap doesn't have objects or is not resolved |
|
| 208 | 208 | { |
| 209 | 209 | foreach ($allObjects as $key => $val) |
| 210 | 210 | { |
| 211 | - if ($val==null) { continue; } |
|
| 211 | + if ($val == null) { continue; } |
|
| 212 | 212 | array_push($this->view->objectList, array( |
| 213 | 213 | $oid_index, |
| 214 | 214 | $key, |
@@ -236,9 +236,9 @@ discard block |
||
| 236 | 236 | // Check if hostname still exists |
| 237 | 237 | $host_get=$this->getUIDatabase()->getHostByName($this->view->hostname); |
| 238 | 238 | |
| 239 | - if (count($host_get)==0) |
|
| 239 | + if (count($host_get) == 0) |
|
| 240 | 240 | { |
| 241 | - $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore'; |
|
| 241 | + $this->view->warning_message='Host '.$this->view->hostname.' doesn\'t exists anymore'; |
|
| 242 | 242 | $this->view->serviceGet=false; |
| 243 | 243 | } |
| 244 | 244 | else |
@@ -246,10 +246,10 @@ discard block |
||
| 246 | 246 | // Tell JS to get services when page is loaded |
| 247 | 247 | $this->view->serviceGet=true; |
| 248 | 248 | // get service id for form to set : |
| 249 | - $serviceID=$this->getUIDatabase()->getServiceIDByName($this->view->hostname,$ruleDetail->service_name); |
|
| 250 | - if (count($serviceID) ==0) |
|
| 249 | + $serviceID=$this->getUIDatabase()->getServiceIDByName($this->view->hostname, $ruleDetail->service_name); |
|
| 250 | + if (count($serviceID) == 0) |
|
| 251 | 251 | { |
| 252 | - $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
|
| 252 | + $this->view->warning_message=' Service '.$ruleDetail->service_name.' doesn\'t exists anymore'; |
|
| 253 | 253 | } |
| 254 | 254 | else |
| 255 | 255 | { |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | { |
| 267 | 267 | // Check if groupe exists |
| 268 | 268 | $group_get=$this->getUIDatabase()->getHostGroupByName($this->view->hostgroupname); |
| 269 | - if (count($group_get)==0) |
|
| 269 | + if (count($group_get) == 0) |
|
| 270 | 270 | { |
| 271 | - $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore'; |
|
| 271 | + $this->view->warning_message='HostGroup '.$this->view->hostgroupname.' doesn\'t exists anymore'; |
|
| 272 | 272 | $this->view->serviceGroupGet=false; |
| 273 | 273 | } |
| 274 | 274 | else |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | // Tell JS to get services when page is loaded |
| 288 | 288 | $this->view->serviceGroupGet=true; |
| 289 | - if ($foundGrpService==0) |
|
| 289 | + if ($foundGrpService == 0) |
|
| 290 | 290 | { |
| 291 | - $this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
|
| 291 | + $this->view->warning_message.=' Service '.$ruleDetail->service_name.' doesn\'t exists anymore'; |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | } |
@@ -306,12 +306,12 @@ discard block |
||
| 306 | 306 | $index=1; |
| 307 | 307 | // check in display & rule for : OID(<oid>) |
| 308 | 308 | $matches=array(); |
| 309 | - while ( preg_match('/_OID\(([\.0-9\*]+)\)/',$display,$matches) || |
|
| 310 | - preg_match('/_OID\(([\.0-9\*]+)\)/',$rule,$matches)) |
|
| 309 | + while (preg_match('/_OID\(([\.0-9\*]+)\)/', $display, $matches) || |
|
| 310 | + preg_match('/_OID\(([\.0-9\*]+)\)/', $rule, $matches)) |
|
| 311 | 311 | { |
| 312 | 312 | $curOid=$matches[1]; |
| 313 | 313 | |
| 314 | - if ( (preg_match('/\*/',$curOid) == 0 ) |
|
| 314 | + if ((preg_match('/\*/', $curOid) == 0) |
|
| 315 | 315 | && ($object=$this->getMIB()->translateOID($curOid)) != null) |
| 316 | 316 | { |
| 317 | 317 | array_push($curObjectList, array( |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | 'not found' |
| 337 | 337 | )); |
| 338 | 338 | } |
| 339 | - $curOid = preg_replace('/\*/','\*',$curOid); |
|
| 340 | - $display=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$display); |
|
| 341 | - $rule=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$rule); |
|
| 339 | + $curOid=preg_replace('/\*/', '\*', $curOid); |
|
| 340 | + $display=preg_replace('/_OID\('.$curOid.'\)/', '\$'.$index.'\$', $display); |
|
| 341 | + $rule=preg_replace('/_OID\('.$curOid.'\)/', '\$'.$index.'\$', $rule); |
|
| 342 | 342 | $index++; |
| 343 | 343 | } |
| 344 | 344 | return $curObjectList; |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | $this->checkConfigPermission(); |
| 354 | 354 | // set up tab |
| 355 | 355 | $this->prepareTabs(); |
| 356 | - $this->getTabs()->add('get',array( |
|
| 356 | + $this->getTabs()->add('get', array( |
|
| 357 | 357 | 'active' => true, |
| 358 | 358 | 'label' => $this->translate('Add handler'), |
| 359 | 359 | 'url' => Url::fromRequest() |
@@ -365,11 +365,11 @@ discard block |
||
| 365 | 365 | $this->view->mibList=$this->getMIB()->getMIBList(); |
| 366 | 366 | |
| 367 | 367 | // Get categories |
| 368 | - $this->view->categoryList = $this->getHandlersCategory(); |
|
| 368 | + $this->view->categoryList=$this->getHandlersCategory(); |
|
| 369 | 369 | |
| 370 | 370 | //$this->view->trapvalues=false; // Set to true to display 'value' colum in objects |
| 371 | 371 | |
| 372 | - if (($trapid = $this->params->get('fromid')) !== null) { |
|
| 372 | + if (($trapid=$this->params->get('fromid')) !== null) { |
|
| 373 | 373 | /********** Setup from existing trap ***************/ |
| 374 | 374 | $this->add_from_existing($trapid); |
| 375 | 375 | return; |
@@ -389,11 +389,11 @@ discard block |
||
| 389 | 389 | $this->view->setRuleMatch=$ruleDetail->action_match; |
| 390 | 390 | $this->view->setRuleNoMatch=$ruleDetail->action_nomatch; |
| 391 | 391 | $this->view->hostgroupname=$ruleDetail->host_group_name; |
| 392 | - $this->view->modified=gmdate("Y-m-d\TH:i:s\Z",$ruleDetail->modified); |
|
| 392 | + $this->view->modified=gmdate("Y-m-d\TH:i:s\Z", $ruleDetail->modified); |
|
| 393 | 393 | $this->view->modifier=$ruleDetail->modifier; |
| 394 | 394 | |
| 395 | - $this->view->comment = $ruleDetail->comment; |
|
| 396 | - $this->view->category = $ruleDetail->category; |
|
| 395 | + $this->view->comment=$ruleDetail->comment; |
|
| 396 | + $this->view->category=$ruleDetail->category; |
|
| 397 | 397 | |
| 398 | 398 | // Warning message if host/service don't exists anymore |
| 399 | 399 | $this->view->warning_message=''; |
@@ -444,28 +444,28 @@ discard block |
||
| 444 | 444 | |
| 445 | 445 | $params=array( |
| 446 | 446 | // id (also db) => array('post' => post id, 'val' => default val, 'db' => send to table) |
| 447 | - 'hostgroup' => array('post' => 'hostgroup', 'db'=>false), |
|
| 448 | - 'db_rule' => array('post' => 'db_rule', 'db'=>false), |
|
| 449 | - 'hostid' => array('post' => 'hostid', 'db'=>false), |
|
| 450 | - 'host_name' => array('post' => 'hostname', 'val' => null, 'db'=>true), |
|
| 451 | - 'host_group_name'=> array('post' => null, 'val' => null, 'db'=>true), |
|
| 452 | - 'serviceid' => array('post' => 'serviceid', 'db'=>false), |
|
| 453 | - 'service_name' => array('post' => 'serviceName', 'db'=>true), |
|
| 454 | - 'comment' => array('post' => 'comment', 'val' => '', 'db'=>true), |
|
| 455 | - 'rule_type' => array('post' => 'category', 'val' => 0, 'db'=>true), |
|
| 456 | - 'trap_oid' => array('post' => 'oid', 'db'=>true), |
|
| 457 | - 'revert_ok' => array('post' => 'revertOK', 'val' => 0, 'db'=>true), |
|
| 458 | - 'display' => array('post' => 'display', 'val' => '', 'db'=>true), |
|
| 459 | - 'rule' => array('post' => 'rule', 'val' => '', 'db'=>true), |
|
| 460 | - 'action_match' => array('post' => 'ruleMatch', 'val' => -1, 'db'=>true), |
|
| 461 | - 'action_nomatch'=> array('post' => 'ruleNoMatch', 'val' => -1, 'db'=>true), |
|
| 462 | - 'ip4' => array('post' => null, 'val' => null, 'db'=>true), |
|
| 463 | - 'ip6' => array('post' => null, 'val' => null, 'db'=>true), |
|
| 464 | - 'action_form' => array('post' => 'action_form', 'val' => null, 'db'=>false) |
|
| 447 | + 'hostgroup' => array('post' => 'hostgroup', 'db'=>false), |
|
| 448 | + 'db_rule' => array('post' => 'db_rule', 'db'=>false), |
|
| 449 | + 'hostid' => array('post' => 'hostid', 'db'=>false), |
|
| 450 | + 'host_name' => array('post' => 'hostname', 'val' => null, 'db'=>true), |
|
| 451 | + 'host_group_name'=> array('post' => null, 'val' => null, 'db'=>true), |
|
| 452 | + 'serviceid' => array('post' => 'serviceid', 'db'=>false), |
|
| 453 | + 'service_name' => array('post' => 'serviceName', 'db'=>true), |
|
| 454 | + 'comment' => array('post' => 'comment', 'val' => '', 'db'=>true), |
|
| 455 | + 'rule_type' => array('post' => 'category', 'val' => 0, 'db'=>true), |
|
| 456 | + 'trap_oid' => array('post' => 'oid', 'db'=>true), |
|
| 457 | + 'revert_ok' => array('post' => 'revertOK', 'val' => 0, 'db'=>true), |
|
| 458 | + 'display' => array('post' => 'display', 'val' => '', 'db'=>true), |
|
| 459 | + 'rule' => array('post' => 'rule', 'val' => '', 'db'=>true), |
|
| 460 | + 'action_match' => array('post' => 'ruleMatch', 'val' => -1, 'db'=>true), |
|
| 461 | + 'action_nomatch'=> array('post' => 'ruleNoMatch', 'val' => -1, 'db'=>true), |
|
| 462 | + 'ip4' => array('post' => null, 'val' => null, 'db'=>true), |
|
| 463 | + 'ip6' => array('post' => null, 'val' => null, 'db'=>true), |
|
| 464 | + 'action_form' => array('post' => 'action_form', 'val' => null, 'db'=>false) |
|
| 465 | 465 | ); |
| 466 | 466 | |
| 467 | 467 | if (isset($postData[$params['action_form']['post']]) |
| 468 | - && $postData[$params['action_form']['post']] == 'delete' ) |
|
| 468 | + && $postData[$params['action_form']['post']] == 'delete') |
|
| 469 | 469 | { |
| 470 | 470 | try |
| 471 | 471 | { |
@@ -485,16 +485,16 @@ discard block |
||
| 485 | 485 | } |
| 486 | 486 | foreach (array_keys($params) as $key) |
| 487 | 487 | { |
| 488 | - if ($params[$key]['post']==null) continue; // data not sent in post vars |
|
| 489 | - if (! isset($postData[$params[$key]['post']])) |
|
| 488 | + if ($params[$key]['post'] == null) continue; // data not sent in post vars |
|
| 489 | + if (!isset($postData[$params[$key]['post']])) |
|
| 490 | 490 | { |
| 491 | 491 | // should not happen as the js checks data |
| 492 | - $this->_helper->json(array('status'=>'No ' . $key)); |
|
| 492 | + $this->_helper->json(array('status'=>'No '.$key)); |
|
| 493 | 493 | } |
| 494 | 494 | else |
| 495 | 495 | { |
| 496 | 496 | $data=$postData[$params[$key]['post']]; |
| 497 | - if ($data!=null && $data !="") |
|
| 497 | + if ($data != null && $data != "") |
|
| 498 | 498 | { |
| 499 | 499 | $params[$key]['val']=$postData[$params[$key]['post']]; |
| 500 | 500 | } |
@@ -503,8 +503,8 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | try |
| 505 | 505 | { |
| 506 | - $isHostGroup=($params['hostgroup']['val'] == 1)?true:false; |
|
| 507 | - if (! $isHostGroup ) |
|
| 506 | + $isHostGroup=($params['hostgroup']['val'] == 1) ?true:false; |
|
| 507 | + if (!$isHostGroup) |
|
| 508 | 508 | { // checks if selection by host |
| 509 | 509 | $hostAddr=$this->getUIDatabase()->getHostInfoByID($params['hostid']['val']); |
| 510 | 510 | $params['ip4']['val']=$hostAddr->ip4; |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | } |
| 518 | 518 | if (!is_numeric($params['serviceid']['val'])) |
| 519 | 519 | { |
| 520 | - $this->_helper->json(array('status'=>"Invalid service id ". $params['serviceid']['val'])); |
|
| 520 | + $this->_helper->json(array('status'=>"Invalid service id ".$params['serviceid']['val'])); |
|
| 521 | 521 | return; |
| 522 | 522 | } |
| 523 | 523 | $serviceName=$this->getUIDatabase()->getObjectNameByid($params['serviceid']['val']); |
@@ -536,15 +536,15 @@ discard block |
||
| 536 | 536 | return; |
| 537 | 537 | } |
| 538 | 538 | // Put param in correct column (group_name) |
| 539 | - $params['host_group_name']['val'] = $params['host_name']['val']; |
|
| 539 | + $params['host_group_name']['val']=$params['host_name']['val']; |
|
| 540 | 540 | $params['host_name']['val']=null; |
| 541 | 541 | } |
| 542 | 542 | $dbparams=array(); |
| 543 | 543 | foreach ($params as $key=>$val) |
| 544 | 544 | { |
| 545 | - if ($val['db']==true ) |
|
| 545 | + if ($val['db'] == true) |
|
| 546 | 546 | { |
| 547 | - $dbparams[$key] = $val['val']; |
|
| 547 | + $dbparams[$key]=$val['val']; |
|
| 548 | 548 | } |
| 549 | 549 | } |
| 550 | 550 | // echo '<br>'; print_r($dbparams);echo '<br>'; |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | else |
| 557 | 557 | { |
| 558 | - $this->getUIDatabase()->updateHandlerRule($dbparams,$params['db_rule']['val']); |
|
| 558 | + $this->getUIDatabase()->updateHandlerRule($dbparams, $params['db_rule']['val']); |
|
| 559 | 559 | $ruleID=$params['db_rule']['val']; |
| 560 | 560 | } |
| 561 | 561 | } |
@@ -574,10 +574,10 @@ discard block |
||
| 574 | 574 | */ |
| 575 | 575 | protected function getTrapDetail($trapid) |
| 576 | 576 | { |
| 577 | - if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id'); } |
|
| 577 | + if (!preg_match('/^[0-9]+$/', $trapid)) { throw new Exception('Invalid id'); } |
|
| 578 | 578 | $queryArray=$this->getModuleConfig()->trapDetailQuery(); |
| 579 | 579 | |
| 580 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 580 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 581 | 581 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 582 | 582 | // *************** Get main data |
| 583 | 583 | // extract columns and titles; |
@@ -587,19 +587,19 @@ discard block |
||
| 587 | 587 | } |
| 588 | 588 | try |
| 589 | 589 | { |
| 590 | - $query = $dbConn->select() |
|
| 591 | - ->from($this->getModuleConfig()->getTrapTableName(),$elmts) |
|
| 592 | - ->where('id=?',$trapid); |
|
| 590 | + $query=$dbConn->select() |
|
| 591 | + ->from($this->getModuleConfig()->getTrapTableName(), $elmts) |
|
| 592 | + ->where('id=?', $trapid); |
|
| 593 | 593 | $trapDetail=$dbConn->fetchRow($query); |
| 594 | - if ( $trapDetail == null ) |
|
| 594 | + if ($trapDetail == null) |
|
| 595 | 595 | { |
| 596 | - $trapDetail = 'NULL'; |
|
| 596 | + $trapDetail='NULL'; |
|
| 597 | 597 | throw new Exception('No traps was found with id = '.$trapid); |
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | catch (Exception $e) |
| 601 | 601 | { |
| 602 | - $this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail,true),$e->getMessage()); |
|
| 602 | + $this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail, true), $e->getMessage()); |
|
| 603 | 603 | return; |
| 604 | 604 | } |
| 605 | 605 | |
@@ -613,10 +613,10 @@ discard block |
||
| 613 | 613 | */ |
| 614 | 614 | protected function getTrapobjects($trapid) |
| 615 | 615 | { |
| 616 | - if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id'); } |
|
| 616 | + if (!preg_match('/^[0-9]+$/', $trapid)) { throw new Exception('Invalid id'); } |
|
| 617 | 617 | $queryArrayData=$this->getModuleConfig()->trapDataDetailQuery(); |
| 618 | 618 | |
| 619 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 619 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 620 | 620 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 621 | 621 | // *************** Get object data |
| 622 | 622 | // extract columns and titles; |
@@ -626,15 +626,15 @@ discard block |
||
| 626 | 626 | } |
| 627 | 627 | try |
| 628 | 628 | { |
| 629 | - $query = $dbConn->select() |
|
| 630 | - ->from($this->moduleConfig->getTrapDataTableName(),$data_elmts) |
|
| 631 | - ->where('trap_id=?',$trapid); |
|
| 629 | + $query=$dbConn->select() |
|
| 630 | + ->from($this->moduleConfig->getTrapDataTableName(), $data_elmts) |
|
| 631 | + ->where('trap_id=?', $trapid); |
|
| 632 | 632 | $trapDetail=$dbConn->fetchAll($query); |
| 633 | 633 | // if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid); |
| 634 | 634 | } |
| 635 | 635 | catch (Exception $e) |
| 636 | 636 | { |
| 637 | - $this->displayExitError('Add handler : get trap data detail : ',$e->getMessage()); |
|
| 637 | + $this->displayExitError('Add handler : get trap data detail : ', $e->getMessage()); |
|
| 638 | 638 | return array(); |
| 639 | 639 | } |
| 640 | 640 | |
@@ -648,24 +648,24 @@ discard block |
||
| 648 | 648 | */ |
| 649 | 649 | protected function getRuleDetail($ruleid) |
| 650 | 650 | { |
| 651 | - if (!preg_match('/^[0-9]+$/',$ruleid)) { throw new Exception('Invalid id'); } |
|
| 651 | + if (!preg_match('/^[0-9]+$/', $ruleid)) { throw new Exception('Invalid id'); } |
|
| 652 | 652 | $queryArray=$this->getModuleConfig()->ruleDetailQuery(); |
| 653 | 653 | |
| 654 | - $dbConn = $this->getUIDatabase()->getDbConn(); |
|
| 654 | + $dbConn=$this->getUIDatabase()->getDbConn(); |
|
| 655 | 655 | if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
| 656 | 656 | // *************** Get main data |
| 657 | 657 | try |
| 658 | 658 | { |
| 659 | - $query = $dbConn->select() |
|
| 660 | - ->from($this->getModuleConfig()->getTrapRuleName(),$queryArray) |
|
| 661 | - ->where('id=?',$ruleid); |
|
| 659 | + $query=$dbConn->select() |
|
| 660 | + ->from($this->getModuleConfig()->getTrapRuleName(), $queryArray) |
|
| 661 | + ->where('id=?', $ruleid); |
|
| 662 | 662 | $ruleDetail=$dbConn->fetchRow($query); |
| 663 | - if ( $ruleDetail == null ) throw new Exception('No rule was found with id = '.$ruleid); |
|
| 663 | + if ($ruleDetail == null) throw new Exception('No rule was found with id = '.$ruleid); |
|
| 664 | 664 | } |
| 665 | 665 | catch (Exception $e) |
| 666 | 666 | { |
| 667 | - $this->displayExitError('Update handler : get rule detail',$e->getMessage()); |
|
| 668 | - throw new Exception('Error : ' . $e->getMessage()); |
|
| 667 | + $this->displayExitError('Update handler : get rule detail', $e->getMessage()); |
|
| 668 | + throw new Exception('Error : '.$e->getMessage()); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | return $ruleDetail; |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | { |
| 679 | 679 | return $this->getTabs()->add('status', array( |
| 680 | 680 | 'label' => $this->translate('Trap handlers'), |
| 681 | - 'url' => $this->getModuleConfig()->urlPath() . '/handler') |
|
| 681 | + 'url' => $this->getModuleConfig()->urlPath().'/handler') |
|
| 682 | 682 | ); |
| 683 | 683 | } |
| 684 | 684 | |