@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | // Filters |
| 23 | 23 | |
| 24 | 24 | protected $filter; |
| 25 | - protected $enforcedFilters = array(); |
|
| 26 | - protected $searchColumns = array(); |
|
| 25 | + protected $enforcedFilters=array(); |
|
| 26 | + protected $searchColumns=array(); |
|
| 27 | 27 | |
| 28 | 28 | protected function getTitles() { |
| 29 | 29 | // TODO : check moduleconfig is set |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | // ****************** Render table in html |
| 34 | 34 | |
| 35 | 35 | // Host grouping |
| 36 | - protected function renderHostIfNew($IP,$hostname) |
|
| 36 | + protected function renderHostIfNew($IP, $hostname) |
|
| 37 | 37 | { |
| 38 | - $view = $this->getView(); |
|
| 38 | + $view=$this->getView(); |
|
| 39 | 39 | |
| 40 | 40 | if ($this->lastHost === $IP) { |
| 41 | 41 | return; |
@@ -43,31 +43,31 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | if ($this->lastHost === null) |
| 45 | 45 | { |
| 46 | - $htm = "<thead>\n <tr>\n"; |
|
| 46 | + $htm="<thead>\n <tr>\n"; |
|
| 47 | 47 | } else { |
| 48 | - $htm = "</tbody>\n<thead>\n <tr>\n"; |
|
| 48 | + $htm="</tbody>\n<thead>\n <tr>\n"; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if ($this->columnCount === null) |
| 52 | 52 | { |
| 53 | - $this->columnCount = count($this->getTitles()); |
|
| 53 | + $this->columnCount=count($this->getTitles()); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($IP); |
|
| 56 | + $htm.='<th colspan="'.$this->columnCount.'">'.$view->escape($IP); |
|
| 57 | 57 | if ($hostname != null) |
| 58 | 58 | { |
| 59 | - $htm .= ' ('.$hostname.')'; |
|
| 59 | + $htm.=' ('.$hostname.')'; |
|
| 60 | 60 | } |
| 61 | - $htm .= '</th>' . "\n"; |
|
| 61 | + $htm.='</th>'."\n"; |
|
| 62 | 62 | if ($this->lastHost === null) { |
| 63 | - $htm .= " </tr>\n"; |
|
| 63 | + $htm.=" </tr>\n"; |
|
| 64 | 64 | } else { |
| 65 | - $htm .= " </tr>\n</thead>\n"; |
|
| 65 | + $htm.=" </tr>\n</thead>\n"; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - $this->lastHost = $IP; |
|
| 68 | + $this->lastHost=$IP; |
|
| 69 | 69 | |
| 70 | - return $htm . "<tbody>\n"; |
|
| 70 | + return $htm."<tbody>\n"; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | public function __toString() |
@@ -78,62 +78,62 @@ discard block |
||
| 78 | 78 | public function render() |
| 79 | 79 | { |
| 80 | 80 | $data=$this->getTable(); |
| 81 | - $view = $this->getView(); |
|
| 82 | - $this->columnCount = count($this->getTitles()); |
|
| 81 | + $view=$this->getView(); |
|
| 82 | + $this->columnCount=count($this->getTitles()); |
|
| 83 | 83 | $this->lastHost=null; |
| 84 | 84 | // Table start |
| 85 | - $htm = '<table class="simple common-table table-row-selectable">'; |
|
| 85 | + $htm='<table class="simple common-table table-row-selectable">'; |
|
| 86 | 86 | |
| 87 | 87 | // Titles |
| 88 | - $htm .= "<thead>\n <tr>\n"; |
|
| 89 | - $titles = $this->getTitles(); |
|
| 88 | + $htm.="<thead>\n <tr>\n"; |
|
| 89 | + $titles=$this->getTitles(); |
|
| 90 | 90 | foreach ($titles as $title) |
| 91 | 91 | { |
| 92 | - $htm .= ' <th>' . $view->escape($view->translate($title)) . "</th>\n"; |
|
| 92 | + $htm.=' <th>'.$view->escape($view->translate($title))."</th>\n"; |
|
| 93 | 93 | } |
| 94 | - $htm .= " </tr>\n</thead>\n"; |
|
| 94 | + $htm.=" </tr>\n</thead>\n"; |
|
| 95 | 95 | |
| 96 | 96 | // Rows |
| 97 | - $htm .= "<tbody>\n"; |
|
| 97 | + $htm.="<tbody>\n"; |
|
| 98 | 98 | |
| 99 | 99 | foreach ($data as $row) |
| 100 | 100 | { |
| 101 | 101 | |
| 102 | - $firstCol = true; |
|
| 102 | + $firstCol=true; |
|
| 103 | 103 | // Put host header |
| 104 | - $source_name=(property_exists($row,'source_name'))?$row->source_name:null; |
|
| 105 | - $htm .= $this->renderHostIfNew($row->source_ip,$source_name); |
|
| 104 | + $source_name=(property_exists($row, 'source_name')) ? $row->source_name : null; |
|
| 105 | + $htm.=$this->renderHostIfNew($row->source_ip, $source_name); |
|
| 106 | 106 | |
| 107 | 107 | |
| 108 | 108 | // Render row |
| 109 | - $htm .= '<tr '.' >'; |
|
| 110 | - foreach ( $titles as $rowkey => $title) |
|
| 109 | + $htm.='<tr '.' >'; |
|
| 110 | + foreach ($titles as $rowkey => $title) |
|
| 111 | 111 | { |
| 112 | 112 | // Check missing value |
| 113 | 113 | if (property_exists($row, $rowkey)) |
| 114 | 114 | { |
| 115 | - $val = ($rowkey=='last_sent') ? strftime('%c',$row->$rowkey) : $row->$rowkey; |
|
| 115 | + $val=($rowkey == 'last_sent') ? strftime('%c', $row->$rowkey) : $row->$rowkey; |
|
| 116 | 116 | } else { |
| 117 | - $val = '-'; |
|
| 117 | + $val='-'; |
|
| 118 | 118 | } |
| 119 | 119 | if ($firstCol === true) { // Put link in first column for trap detail. |
| 120 | - $htm .= '<td>' |
|
| 120 | + $htm.='<td>' |
|
| 121 | 121 | . $view->qlink( |
| 122 | 122 | $view->escape($val), |
| 123 | 123 | Url::fromPath( |
| 124 | - $this->moduleConfig->urlPath() . '/received', |
|
| 124 | + $this->moduleConfig->urlPath().'/received', |
|
| 125 | 125 | array('q' => $row->trap_oid) |
| 126 | 126 | ) |
| 127 | 127 | ) |
| 128 | 128 | . '</td>'; |
| 129 | 129 | } else { |
| 130 | - $htm .= '<td>' . $view->escape($val) . '</td>'; |
|
| 130 | + $htm.='<td>'.$view->escape($val).'</td>'; |
|
| 131 | 131 | } |
| 132 | 132 | $firstCol=false; |
| 133 | 133 | } |
| 134 | - $htm .= "<tr>\n"; |
|
| 134 | + $htm.="<tr>\n"; |
|
| 135 | 135 | } |
| 136 | - $htm .= "</tbody></table>\n"; |
|
| 136 | + $htm.="</tbody></table>\n"; |
|
| 137 | 137 | //$htm .= "Filter : " . $this->filter."<br>\n"; |
| 138 | 138 | return $htm; |
| 139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | $db=$this->db(); |
| 145 | 145 | |
| 146 | - $query = $this->getBaseQuery(); |
|
| 146 | + $query=$this->getBaseQuery(); |
|
| 147 | 147 | $this->applyFiltersToQuery($query); |
| 148 | 148 | $values=$db->fetchAll($query); |
| 149 | 149 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | public function getPaginator() |
| 156 | 156 | { |
| 157 | - $paginator = new Paginator(); |
|
| 157 | + $paginator=new Paginator(); |
|
| 158 | 158 | $paginator->setQuery($this); |
| 159 | 159 | |
| 160 | 160 | return $paginator; |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | $db=$this->db(); |
| 168 | 168 | |
| 169 | - $query = $this->getBaseQuery(); |
|
| 169 | + $query=$this->getBaseQuery(); |
|
| 170 | 170 | $this->applyFiltersToQuery($query); |
| 171 | 171 | if ($this->hasLimit() || $this->hasOffset()) { |
| 172 | 172 | $query->limit($this->getLimit(), $this->getOffset()); |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | public function getBaseQuery() |
| 179 | 179 | { |
| 180 | 180 | $db=$this->db(); |
| 181 | - $query = $db->select()->from( |
|
| 181 | + $query=$db->select()->from( |
|
| 182 | 182 | $this->moduleConfig->getTrapTableName(), |
| 183 | 183 | $this->moduleConfig->getTrapHostListDisplayColumns() |
| 184 | - )->group(array('t.source_ip','t.source_name','t.trap_oid')) |
|
| 184 | + )->group(array('t.source_ip', 't.source_name', 't.trap_oid')) |
|
| 185 | 185 | ->order('t.source_ip'); |
| 186 | 186 | |
| 187 | 187 | return $query; |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | protected $filter_Handler; |
| 193 | 193 | protected $filter_query=''; |
| 194 | 194 | protected $filter_done=''; |
| 195 | - protected $filter_query_list=array('q','done'); |
|
| 195 | + protected $filter_query_list=array('q', 'done'); |
|
| 196 | 196 | public function renderFilterHTML() |
| 197 | 197 | { |
| 198 | 198 | $htm=' <form id="filter" name="mainFilter" |
@@ -202,17 +202,17 @@ discard block |
||
| 202 | 202 | $htm.='<input type="text" name="q" title="Search is simple! Try to combine multiple words" |
| 203 | 203 | placeholder="Search..." class="search" value="'.$this->filter_query.'">'; |
| 204 | 204 | $htm.='<input type="checkbox" id="checkbox_done" name="done" value="1" class="autosubmit" '; |
| 205 | - if ($this->filter_done == 1) { $htm.=' checked ';} |
|
| 205 | + if ($this->filter_done == 1) { $htm.=' checked '; } |
|
| 206 | 206 | $htm.='> <label for="checkbox_done">Hide processed traps</label>'; |
| 207 | 207 | $htm.='</form>'; |
| 208 | 208 | return $htm; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - public function updateFilter($handler,$filter) |
|
| 211 | + public function updateFilter($handler, $filter) |
|
| 212 | 212 | { |
| 213 | 213 | $this->filter_Handler=$handler->remove($this->filter_query_list)->__toString(); |
| 214 | - $this->filter_query=(isset($filter['q']))?$this->filter_query=$filter['q']:''; |
|
| 215 | - $this->filter_done=(isset($filter['done']))?$this->filter_done=$filter['done']:0; |
|
| 214 | + $this->filter_query=(isset($filter['q'])) ? $this->filter_query=$filter['q'] : ''; |
|
| 215 | + $this->filter_done=(isset($filter['done'])) ? $this->filter_done=$filter['done'] : 0; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | protected function getSearchColumns() |
@@ -227,20 +227,20 @@ discard block |
||
| 227 | 227 | |
| 228 | 228 | public function setFilter($filter) |
| 229 | 229 | { |
| 230 | - $this->filter = $filter; |
|
| 230 | + $this->filter=$filter; |
|
| 231 | 231 | return $this; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | public function getFilterEditor(Request $request) |
| 235 | 235 | { |
| 236 | - $filterEditor = Widget::create('filterEditor') |
|
| 236 | + $filterEditor=Widget::create('filterEditor') |
|
| 237 | 237 | ->setColumns(array_keys($this->getColumns())) |
| 238 | 238 | ->setSearchColumns(array_keys($this->getSearchColumns())) |
| 239 | 239 | ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') |
| 240 | 240 | ->ignoreParams('page') |
| 241 | 241 | ->handleRequest($request); |
| 242 | 242 | |
| 243 | - $filter = $filterEditor->getFilter(); |
|
| 243 | + $filter=$filterEditor->getFilter(); |
|
| 244 | 244 | $this->setFilter($filter); |
| 245 | 245 | |
| 246 | 246 | return $filterEditor; |
@@ -254,9 +254,9 @@ discard block |
||
| 254 | 254 | { |
| 255 | 255 | $sql.='('; |
| 256 | 256 | $first=1; |
| 257 | - foreach($this->moduleConfig->getTrapListSearchColumns() as $column) |
|
| 257 | + foreach ($this->moduleConfig->getTrapListSearchColumns() as $column) |
|
| 258 | 258 | { |
| 259 | - if ($first==0) $sql.=' OR '; |
|
| 259 | + if ($first == 0) $sql.=' OR '; |
|
| 260 | 260 | $first=0; |
| 261 | 261 | $sql.=" ".$column." LIKE '%".$this->filter_query."%' "; |
| 262 | 262 | } |
@@ -22,14 +22,14 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | class TrapsController extends Controller |
| 24 | 24 | { |
| 25 | - protected $moduleConfig; //< TrapModuleConfig instance |
|
| 26 | - protected $trapTableList; //< TrapTableList (by date) |
|
| 27 | - protected $trapTableHostList; //< TrapTableList (by hosts) |
|
| 28 | - protected $handlerTableList; //< HandlerTableList instance |
|
| 29 | - protected $trapDB; //< Trap database |
|
| 30 | - protected $icingaDB; //< Icinga IDO database; |
|
| 31 | - protected $MIBData; //< MIBLoader class |
|
| 32 | - protected $trapClass; //< Trap class for bin/trap_class.php |
|
| 25 | + protected $moduleConfig; //< TrapModuleConfig instance |
|
| 26 | + protected $trapTableList; //< TrapTableList (by date) |
|
| 27 | + protected $trapTableHostList; //< TrapTableList (by hosts) |
|
| 28 | + protected $handlerTableList; //< HandlerTableList instance |
|
| 29 | + protected $trapDB; //< Trap database |
|
| 30 | + protected $icingaDB; //< Icinga IDO database; |
|
| 31 | + protected $MIBData; //< MIBLoader class |
|
| 32 | + protected $trapClass; //< Trap class for bin/trap_class.php |
|
| 33 | 33 | |
| 34 | 34 | /** Get instance of TrapModuleConfig class |
| 35 | 35 | * @return TrapModuleConfig |
@@ -43,14 +43,14 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $this->redirectNow('trapdirector/settings?message=No database prefix'); |
| 45 | 45 | } |
| 46 | - $this->moduleConfig = new TrapModuleConfig($db_prefix); |
|
| 46 | + $this->moduleConfig=new TrapModuleConfig($db_prefix); |
|
| 47 | 47 | } |
| 48 | 48 | return $this->moduleConfig; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public function getTrapListTable() { |
| 52 | 52 | if ($this->trapTableList == Null) { |
| 53 | - $this->trapTableList = new TrapTableList(); |
|
| 53 | + $this->trapTableList=new TrapTableList(); |
|
| 54 | 54 | $this->trapTableList->setConfig($this->getModuleConfig()); |
| 55 | 55 | } |
| 56 | 56 | return $this->trapTableList; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | if ($this->trapTableHostList == Null) |
| 62 | 62 | { |
| 63 | - $this->trapTableHostList = new TrapTableHostList(); |
|
| 63 | + $this->trapTableHostList=new TrapTableHostList(); |
|
| 64 | 64 | $this->trapTableHostList->setConfig($this->getModuleConfig()); |
| 65 | 65 | } |
| 66 | 66 | return $this->trapTableHostList; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | if ($this->handlerTableList == Null) |
| 72 | 72 | { |
| 73 | - $this->handlerTableList = new HandlerTableList(); |
|
| 73 | + $this->handlerTableList=new HandlerTableList(); |
|
| 74 | 74 | $this->handlerTableList->setConfig($this->getModuleConfig()); |
| 75 | 75 | } |
| 76 | 76 | return $this->handlerTableList; |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | * @param $test_version bool if set to flase, does not test database version of trapDB |
| 83 | 83 | * @return array<integer,mixed>|mixed : if test=false, returns DB connexion, else array(error_num,message) or null on error. |
| 84 | 84 | */ |
| 85 | - public function getDbByName($DBname,$test=false,$test_version=true) |
|
| 85 | + public function getDbByName($DBname, $test=false, $test_version=true) |
|
| 86 | 86 | { |
| 87 | 87 | try |
| 88 | 88 | { |
| 89 | - $dbconn = IcingaDbConnection::fromResourceName($DBname); |
|
| 89 | + $dbconn=IcingaDbConnection::fromResourceName($DBname); |
|
| 90 | 90 | } |
| 91 | 91 | catch (Exception $e) |
| 92 | 92 | { |
| 93 | - if ($test) return array(2,$DBname); |
|
| 93 | + if ($test) return array(2, $DBname); |
|
| 94 | 94 | $this->redirectNow('trapdirector/settings?dberror=2'); |
| 95 | 95 | return null; |
| 96 | 96 | } |
@@ -101,53 +101,53 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | catch (Exception $e) |
| 103 | 103 | { |
| 104 | - if ($test) return array(3,$DBname,$e->getMessage()); |
|
| 104 | + if ($test) return array(3, $DBname, $e->getMessage()); |
|
| 105 | 105 | $this->redirectNow('trapdirector/settings?dberror=3'); |
| 106 | 106 | return null; |
| 107 | 107 | } |
| 108 | 108 | try |
| 109 | 109 | { |
| 110 | - $query = $db->select() |
|
| 111 | - ->from($this->getModuleConfig()->getDbConfigTableName(),'value') |
|
| 110 | + $query=$db->select() |
|
| 111 | + ->from($this->getModuleConfig()->getDbConfigTableName(), 'value') |
|
| 112 | 112 | ->where('name=\'db_version\''); |
| 113 | 113 | $version=$db->fetchRow($query); |
| 114 | - if ( ($version == null) || ! property_exists($version,'value') ) |
|
| 114 | + if (($version == null) || !property_exists($version, 'value')) |
|
| 115 | 115 | { |
| 116 | - if ($test) return array(4,$DBname); |
|
| 116 | + if ($test) return array(4, $DBname); |
|
| 117 | 117 | $this->redirectNow('trapdirector/settings?dberror=4'); |
| 118 | 118 | return null; |
| 119 | 119 | } |
| 120 | 120 | if ($version->value < $this->getModuleConfig()->getDbMinVersion()) |
| 121 | 121 | { |
| 122 | - if ($test) return array(5,$version->value,$this->getModuleConfig()->getDbMinVersion()); |
|
| 122 | + if ($test) return array(5, $version->value, $this->getModuleConfig()->getDbMinVersion()); |
|
| 123 | 123 | $this->redirectNow('trapdirector/settings?dberror=5'); |
| 124 | 124 | return null; |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | catch (Exception $e) |
| 128 | 128 | { |
| 129 | - if ($test) return array(3,$DBname,$e->getMessage()); |
|
| 129 | + if ($test) return array(3, $DBname, $e->getMessage()); |
|
| 130 | 130 | $this->redirectNow('trapdirector/settings?dberror=4'); |
| 131 | 131 | return null; |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | - if ($test) return array(0,''); |
|
| 134 | + if ($test) return array(0, ''); |
|
| 135 | 135 | return $dbconn; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | public function getDb($test=false) |
| 139 | 139 | { |
| 140 | - if ($this->trapDB != null && $test = false) return $this->trapDB; |
|
| 140 | + if ($this->trapDB != null && $test=false) return $this->trapDB; |
|
| 141 | 141 | |
| 142 | 142 | $dbresource=$this->Config()->get('config', 'database'); |
| 143 | 143 | |
| 144 | - if ( ! $dbresource ) |
|
| 144 | + if (!$dbresource) |
|
| 145 | 145 | { |
| 146 | - if ($test) return array(1,''); |
|
| 146 | + if ($test) return array(1, ''); |
|
| 147 | 147 | $this->redirectNow('trapdirector/settings?dberror=1'); |
| 148 | 148 | return null; |
| 149 | 149 | } |
| 150 | - $retDB=$this->getDbByName($dbresource,$test,true); |
|
| 150 | + $retDB=$this->getDbByName($dbresource, $test, true); |
|
| 151 | 151 | if ($test == true) return $retDB; |
| 152 | 152 | $this->trapDB=$retDB; |
| 153 | 153 | return $this->trapDB; |
@@ -155,78 +155,78 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | public function getIdoDb($test=false) |
| 157 | 157 | { |
| 158 | - if ($this->icingaDB != null && $test = false) return $this->icingaDB; |
|
| 158 | + if ($this->icingaDB != null && $test=false) return $this->icingaDB; |
|
| 159 | 159 | // TODO : get ido database directly from icingaweb2 config -> (or not if using only API) |
| 160 | - $dbresource=$this->Config()->get('config', 'IDOdatabase');; |
|
| 160 | + $dbresource=$this->Config()->get('config', 'IDOdatabase'); ; |
|
| 161 | 161 | |
| 162 | - if ( ! $dbresource ) |
|
| 162 | + if (!$dbresource) |
|
| 163 | 163 | { |
| 164 | - if ($test) return array(1,'No database in config.ini'); |
|
| 164 | + if ($test) return array(1, 'No database in config.ini'); |
|
| 165 | 165 | $this->redirectNow('trapdirector/settings?idodberror=1'); |
| 166 | 166 | return null; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | try |
| 170 | 170 | { |
| 171 | - $dbconn = IcingaDbConnection::fromResourceName($dbresource); |
|
| 171 | + $dbconn=IcingaDbConnection::fromResourceName($dbresource); |
|
| 172 | 172 | } |
| 173 | 173 | catch (Exception $e) |
| 174 | 174 | { |
| 175 | - if ($test) return array(2,"Database $dbresource does not exists in IcingaWeb2"); |
|
| 175 | + if ($test) return array(2, "Database $dbresource does not exists in IcingaWeb2"); |
|
| 176 | 176 | $this->redirectNow('trapdirector/settings?idodberror=2'); |
| 177 | 177 | return null; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | if ($test == false) |
| 181 | 181 | { |
| 182 | - $this->icingaDB = $dbconn; |
|
| 182 | + $this->icingaDB=$dbconn; |
|
| 183 | 183 | return $this->icingaDB; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | try |
| 187 | 187 | { |
| 188 | - $query = $dbconn->select() |
|
| 189 | - ->from('icinga_dbversion',array('version')); |
|
| 188 | + $query=$dbconn->select() |
|
| 189 | + ->from('icinga_dbversion', array('version')); |
|
| 190 | 190 | $version=$dbconn->fetchRow($query); |
| 191 | - if ( ($version == null) || ! property_exists($version,'version') ) |
|
| 191 | + if (($version == null) || !property_exists($version, 'version')) |
|
| 192 | 192 | { |
| 193 | - return array(4,"$dbresource does not look like an IDO database"); |
|
| 193 | + return array(4, "$dbresource does not look like an IDO database"); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | catch (Exception $e) |
| 197 | 197 | { |
| 198 | - return array(3,"Error connecting to $dbresource : " . $e->getMessage()); |
|
| 198 | + return array(3, "Error connecting to $dbresource : ".$e->getMessage()); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - return array(0,''); |
|
| 201 | + return array(0, ''); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - protected function applyPaginationLimits(Paginatable $paginatable, $limit = 25, $offset = null) |
|
| 204 | + protected function applyPaginationLimits(Paginatable $paginatable, $limit=25, $offset=null) |
|
| 205 | 205 | { |
| 206 | - $limit = $this->params->get('limit', $limit); |
|
| 207 | - $page = $this->params->get('page', $offset); |
|
| 206 | + $limit=$this->params->get('limit', $limit); |
|
| 207 | + $page=$this->params->get('page', $offset); |
|
| 208 | 208 | |
| 209 | 209 | $paginatable->limit($limit, $page > 0 ? ($page - 1) * $limit : 0); |
| 210 | 210 | |
| 211 | 211 | return $paginatable; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - public function displayExitError($source,$message) |
|
| 214 | + public function displayExitError($source, $message) |
|
| 215 | 215 | { // TODO : check better ways to transmit data (with POST ?) |
| 216 | 216 | $this->redirectNow('trapdirector/error?source='.$source.'&message='.$message); |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | protected function checkReadPermission() |
| 220 | 220 | { |
| 221 | - if (! $this->Auth()->hasPermission('trapdirector/view')) { |
|
| 222 | - $this->displayExitError('Permissions','No permission fo view content'); |
|
| 221 | + if (!$this->Auth()->hasPermission('trapdirector/view')) { |
|
| 222 | + $this->displayExitError('Permissions', 'No permission fo view content'); |
|
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | protected function checkConfigPermission() |
| 227 | 227 | { |
| 228 | - if (! $this->Auth()->hasPermission('trapdirector/config')) { |
|
| 229 | - $this->displayExitError('Permissions','No permission fo configure'); |
|
| 228 | + if (!$this->Auth()->hasPermission('trapdirector/config')) { |
|
| 229 | + $this->displayExitError('Permissions', 'No permission fo configure'); |
|
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | */ |
| 238 | 238 | protected function checkModuleConfigPermission($check=0) |
| 239 | 239 | { |
| 240 | - if (! $this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 240 | + if (!$this->Auth()->hasPermission('trapdirector/module_config')) { |
|
| 241 | 241 | if ($check == 0) |
| 242 | 242 | { |
| 243 | - $this->displayExitError('Permissions','No permission fo configure module'); |
|
| 243 | + $this->displayExitError('Permissions', 'No permission fo configure module'); |
|
| 244 | 244 | } |
| 245 | 245 | return false; |
| 246 | 246 | } |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | { // TODO : try/catch here ? or within caller |
| 253 | 253 | if ($this->trapClass == null) |
| 254 | 254 | { |
| 255 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 255 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 256 | 256 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 257 | 257 | //$debug_level=4; |
| 258 | - $this->trapClass = new Trap($icingaweb2_etc); |
|
| 258 | + $this->trapClass=new Trap($icingaweb2_etc); |
|
| 259 | 259 | //$Trap->setLogging($debug_level,'syslog'); |
| 260 | 260 | } |
| 261 | 261 | return $this->trapClass; |
@@ -289,12 +289,12 @@ discard block |
||
| 289 | 289 | protected function getHostByIP($ip) |
| 290 | 290 | { |
| 291 | 291 | // 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 |
| 292 | - $db = $this->getIdoDb()->getConnection(); |
|
| 292 | + $db=$this->getIdoDb()->getConnection(); |
|
| 293 | 293 | // TODO : check for SQL injections |
| 294 | 294 | $query=$db->select() |
| 295 | 295 | ->from( |
| 296 | 296 | array('a' => 'icinga_objects'), |
| 297 | - array('name' => 'a.name1','id' => 'object_id')) |
|
| 297 | + array('name' => 'a.name1', 'id' => 'object_id')) |
|
| 298 | 298 | ->join( |
| 299 | 299 | array('b' => 'icinga_hosts'), |
| 300 | 300 | 'b.host_object_id=a.object_id', |
@@ -310,12 +310,12 @@ discard block |
||
| 310 | 310 | protected function getHostByName($name) |
| 311 | 311 | { |
| 312 | 312 | // 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 |
| 313 | - $db = $this->getIdoDb()->getConnection(); |
|
| 313 | + $db=$this->getIdoDb()->getConnection(); |
|
| 314 | 314 | // TODO : check for SQL injections |
| 315 | 315 | $query=$db->select() |
| 316 | 316 | ->from( |
| 317 | 317 | array('a' => 'icinga_objects'), |
| 318 | - array('name' => 'a.name1','id' => 'object_id')) |
|
| 318 | + array('name' => 'a.name1', 'id' => 'object_id')) |
|
| 319 | 319 | ->join( |
| 320 | 320 | array('b' => 'icinga_hosts'), |
| 321 | 321 | 'b.host_object_id=a.object_id', |
@@ -331,12 +331,12 @@ discard block |
||
| 331 | 331 | protected function getHostGroupByName($ip) |
| 332 | 332 | { |
| 333 | 333 | // 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 |
| 334 | - $db = $this->getIdoDb()->getConnection(); |
|
| 334 | + $db=$this->getIdoDb()->getConnection(); |
|
| 335 | 335 | // TODO : check for SQL injections |
| 336 | 336 | $query=$db->select() |
| 337 | 337 | ->from( |
| 338 | 338 | array('a' => 'icinga_objects'), |
| 339 | - array('name' => 'a.name1','id' => 'object_id')) |
|
| 339 | + array('name' => 'a.name1', 'id' => 'object_id')) |
|
| 340 | 340 | ->join( |
| 341 | 341 | array('b' => 'icinga_hostgroups'), |
| 342 | 342 | 'b.hostgroup_object_id=a.object_id', |
@@ -352,8 +352,8 @@ discard block |
||
| 352 | 352 | */ |
| 353 | 353 | protected function getHostInfoByID($id) |
| 354 | 354 | { |
| 355 | - if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
|
| 356 | - $db = $this->getIdoDb()->getConnection(); |
|
| 355 | + if (!preg_match('/^[0-9]+$/', $id)) { throw new Exception('Invalid id'); } |
|
| 356 | + $db=$this->getIdoDb()->getConnection(); |
|
| 357 | 357 | $query=$db->select() |
| 358 | 358 | ->from( |
| 359 | 359 | array('a' => 'icinga_objects'), |
@@ -373,17 +373,17 @@ discard block |
||
| 373 | 373 | */ |
| 374 | 374 | protected function getHostByObjectID($id) // TODO : duplicate of getHostInfoByID above |
| 375 | 375 | { |
| 376 | - if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
|
| 377 | - $db = $this->getIdoDb()->getConnection(); |
|
| 376 | + if (!preg_match('/^[0-9]+$/', $id)) { throw new Exception('Invalid id'); } |
|
| 377 | + $db=$this->getIdoDb()->getConnection(); |
|
| 378 | 378 | $query=$db->select() |
| 379 | 379 | ->from( |
| 380 | 380 | array('a' => 'icinga_objects'), |
| 381 | - array('name' => 'a.name1','id' => 'a.object_id')) |
|
| 381 | + array('name' => 'a.name1', 'id' => 'a.object_id')) |
|
| 382 | 382 | ->join( |
| 383 | 383 | array('b' => 'icinga_hosts'), |
| 384 | 384 | 'b.host_object_id=a.object_id', |
| 385 | - array('display_name' => 'b.display_name' , 'ip' => 'b.address', 'ip6' => 'b.address6')) |
|
| 386 | - ->where('a.object_id = ?',$id); |
|
| 385 | + array('display_name' => 'b.display_name', 'ip' => 'b.address', 'ip6' => 'b.address6')) |
|
| 386 | + ->where('a.object_id = ?', $id); |
|
| 387 | 387 | return $db->fetchRow($query); |
| 388 | 388 | } |
| 389 | 389 | |
@@ -395,16 +395,16 @@ discard block |
||
| 395 | 395 | protected function getServicesByHostid($id) |
| 396 | 396 | { |
| 397 | 397 | // 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 |
| 398 | - if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
|
| 399 | - $db = $this->getIdoDb()->getConnection(); |
|
| 398 | + if (!preg_match('/^[0-9]+$/', $id)) { throw new Exception('Invalid id'); } |
|
| 399 | + $db=$this->getIdoDb()->getConnection(); |
|
| 400 | 400 | $query=$db->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', |
| 407 | - array('is_active'=>'a.is_active','name2'=>'a.name2')) |
|
| 407 | + array('is_active'=>'a.is_active', 'name2'=>'a.name2')) |
|
| 408 | 408 | ->where('s.host_object_id='.$id.' AND a.is_active = 1'); |
| 409 | 409 | |
| 410 | 410 | return $db->fetchAll($query); |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | protected function getServicesByHostGroupid($id) |
| 420 | 420 | { |
| 421 | - if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
|
| 422 | - $db = $this->getIdoDb()->getConnection(); |
|
| 421 | + if (!preg_match('/^[0-9]+$/', $id)) { throw new Exception('Invalid id'); } |
|
| 422 | + $db=$this->getIdoDb()->getConnection(); |
|
| 423 | 423 | $query=$db->select() |
| 424 | 424 | ->from( |
| 425 | 425 | array('s' => 'icinga_hostgroup_members'), |
@@ -436,11 +436,11 @@ discard block |
||
| 436 | 436 | foreach ($hosts as $key => $host) |
| 437 | 437 | { // For each host, get all services and add in common_services if not found or add counter |
| 438 | 438 | $host_services=$this->getServicesByHostid($host->host_object_id); |
| 439 | - foreach($host_services as $service) |
|
| 439 | + foreach ($host_services as $service) |
|
| 440 | 440 | { |
| 441 | 441 | if (isset($common_services[$service->name2]['num'])) |
| 442 | 442 | { |
| 443 | - $common_services[$service->name2]['num'] +=1; |
|
| 443 | + $common_services[$service->name2]['num']+=1; |
|
| 444 | 444 | } |
| 445 | 445 | else |
| 446 | 446 | { |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | { |
| 457 | 457 | if ($common_services[$key]['num'] == $num_hosts) |
| 458 | 458 | { |
| 459 | - array_push($result,array($key,$common_services[$key]['name'])); |
|
| 459 | + array_push($result, array($key, $common_services[$key]['name'])); |
|
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | |
@@ -469,9 +469,9 @@ discard block |
||
| 469 | 469 | * @param $name string service name |
| 470 | 470 | * @return array service id |
| 471 | 471 | */ |
| 472 | - protected function getServiceIDByName($hostname,$name) |
|
| 472 | + protected function getServiceIDByName($hostname, $name) |
|
| 473 | 473 | { |
| 474 | - $db = $this->getIdoDb()->getConnection(); |
|
| 474 | + $db=$this->getIdoDb()->getConnection(); |
|
| 475 | 475 | if ($name == null) |
| 476 | 476 | { |
| 477 | 477 | return array(); |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | $query=$db->select() |
| 481 | 481 | ->from( |
| 482 | 482 | array('s' => 'icinga_services'), |
| 483 | - array('name' => 's.display_name','id' => 's.service_object_id')) |
|
| 483 | + array('name' => 's.display_name', 'id' => 's.service_object_id')) |
|
| 484 | 484 | ->join( |
| 485 | 485 | array('a' => 'icinga_objects'), |
| 486 | 486 | 's.service_object_id=a.object_id', |
@@ -498,12 +498,12 @@ discard block |
||
| 498 | 498 | protected function getObjectNameByid($id) |
| 499 | 499 | { |
| 500 | 500 | // 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 |
| 501 | - if (!preg_match('/^[0-9]+$/',$id)) { throw new Exception('Invalid id'); } |
|
| 502 | - $db = $this->getIdoDb()->getConnection(); |
|
| 501 | + if (!preg_match('/^[0-9]+$/', $id)) { throw new Exception('Invalid id'); } |
|
| 502 | + $db=$this->getIdoDb()->getConnection(); |
|
| 503 | 503 | $query=$db->select() |
| 504 | 504 | ->from( |
| 505 | 505 | array('a' => 'icinga_objects'), |
| 506 | - array('name1' => 'a.name1','name2' => 'a.name2')) |
|
| 506 | + array('name1' => 'a.name1', 'name2' => 'a.name2')) |
|
| 507 | 507 | ->where('a.object_id='.$id.' AND a.is_active = 1'); |
| 508 | 508 | |
| 509 | 509 | return $db->fetchRow($query); |
@@ -516,17 +516,17 @@ discard block |
||
| 516 | 516 | protected function addHandlerRule($params) |
| 517 | 517 | { |
| 518 | 518 | // TODO Check for rule consistency |
| 519 | - $db = $this->getDb()->getConnection(); |
|
| 519 | + $db=$this->getDb()->getConnection(); |
|
| 520 | 520 | // Add last modified date = creation date and username |
| 521 | - $params['created'] = new Zend_Db_Expr('NOW()'); |
|
| 522 | - $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 523 | - $params['modifier'] = $this->Auth()->getUser()->getUsername(); |
|
| 521 | + $params['created']=new Zend_Db_Expr('NOW()'); |
|
| 522 | + $params['modified']=new Zend_Db_Expr('NOW()'); |
|
| 523 | + $params['modifier']=$this->Auth()->getUser()->getUsername(); |
|
| 524 | 524 | |
| 525 | 525 | $query=$db->insert( |
| 526 | 526 | $this->getModuleConfig()->getTrapRuleName(), |
| 527 | 527 | $params |
| 528 | 528 | ); |
| 529 | - if($query==false) |
|
| 529 | + if ($query == false) |
|
| 530 | 530 | { |
| 531 | 531 | return null; |
| 532 | 532 | } |
@@ -537,13 +537,13 @@ discard block |
||
| 537 | 537 | * @param array(<db item>=><value>) |
| 538 | 538 | * @return array affected rows |
| 539 | 539 | */ |
| 540 | - protected function updateHandlerRule($params,$ruleID) |
|
| 540 | + protected function updateHandlerRule($params, $ruleID) |
|
| 541 | 541 | { |
| 542 | 542 | // TODO Check for rule consistency |
| 543 | - $db = $this->getDb()->getConnection(); |
|
| 543 | + $db=$this->getDb()->getConnection(); |
|
| 544 | 544 | // Add last modified date = creation date and username |
| 545 | - $params['modified'] = new Zend_Db_Expr('NOW()'); |
|
| 546 | - $params['modifier'] = $this->Auth()->getUser()->getUsername(); |
|
| 545 | + $params['modified']=new Zend_Db_Expr('NOW()'); |
|
| 546 | + $params['modifier']=$this->Auth()->getUser()->getUsername(); |
|
| 547 | 547 | |
| 548 | 548 | $numRows=$db->update( |
| 549 | 549 | $this->getModuleConfig()->getTrapRuleName(), |
@@ -558,8 +558,8 @@ discard block |
||
| 558 | 558 | */ |
| 559 | 559 | protected function deleteRule($ruleID) |
| 560 | 560 | { |
| 561 | - if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id'); } |
|
| 562 | - $db = $this->getDb()->getConnection(); |
|
| 561 | + if (!preg_match('/^[0-9]+$/', $ruleID)) { throw new Exception('Invalid id'); } |
|
| 562 | + $db=$this->getDb()->getConnection(); |
|
| 563 | 563 | |
| 564 | 564 | $query=$db->delete( |
| 565 | 565 | $this->getModuleConfig()->getTrapRuleName(), |
@@ -572,10 +572,10 @@ discard block |
||
| 572 | 572 | * @param $ip string source IP (v4 or v6) |
| 573 | 573 | * @param $oid string oid |
| 574 | 574 | */ |
| 575 | - protected function deleteTrap($ip,$oid) |
|
| 575 | + protected function deleteTrap($ip, $oid) |
|
| 576 | 576 | { |
| 577 | 577 | |
| 578 | - $db = $this->getDb()->getConnection(); |
|
| 578 | + $db=$this->getDb()->getConnection(); |
|
| 579 | 579 | $condition=null; |
| 580 | 580 | if ($ip != null) |
| 581 | 581 | { |
@@ -583,10 +583,10 @@ discard block |
||
| 583 | 583 | } |
| 584 | 584 | if ($oid != null) |
| 585 | 585 | { |
| 586 | - $condition=($condition===null)?'':$condition.' AND '; |
|
| 586 | + $condition=($condition === null) ? '' : $condition.' AND '; |
|
| 587 | 587 | $condition.="trap_oid='$oid'"; |
| 588 | 588 | } |
| 589 | - if($condition === null) return null; |
|
| 589 | + if ($condition === null) return null; |
|
| 590 | 590 | $query=$db->delete( |
| 591 | 591 | $this->getModuleConfig()->getTrapTableName(), |
| 592 | 592 | $condition |
@@ -600,10 +600,10 @@ discard block |
||
| 600 | 600 | * @param $ip string source IP (v4 or v6) |
| 601 | 601 | * @param $oid string oid |
| 602 | 602 | */ |
| 603 | - protected function countTrap($ip,$oid) |
|
| 603 | + protected function countTrap($ip, $oid) |
|
| 604 | 604 | { |
| 605 | 605 | |
| 606 | - $db = $this->getDb()->getConnection(); |
|
| 606 | + $db=$this->getDb()->getConnection(); |
|
| 607 | 607 | $condition=null; |
| 608 | 608 | if ($ip != null) |
| 609 | 609 | { |
@@ -611,10 +611,10 @@ discard block |
||
| 611 | 611 | } |
| 612 | 612 | if ($oid != null) |
| 613 | 613 | { |
| 614 | - $condition=($condition==null)?'':$condition.' AND '; |
|
| 614 | + $condition=($condition == null) ? '' : $condition.' AND '; |
|
| 615 | 615 | $condition.="trap_oid='$oid'"; |
| 616 | 616 | } |
| 617 | - if($condition ==null) return 0; |
|
| 617 | + if ($condition == null) return 0; |
|
| 618 | 618 | $query=$db->select() |
| 619 | 619 | ->from( |
| 620 | 620 | $this->getModuleConfig()->getTrapTableName(), |
@@ -630,27 +630,27 @@ discard block |
||
| 630 | 630 | protected function getDBConfigValue($element) |
| 631 | 631 | { |
| 632 | 632 | |
| 633 | - $db = $this->getDb()->getConnection(); |
|
| 633 | + $db=$this->getDb()->getConnection(); |
|
| 634 | 634 | |
| 635 | 635 | $query=$db->select() |
| 636 | 636 | ->from( |
| 637 | 637 | $this->getModuleConfig()->getDbConfigTableName(), |
| 638 | 638 | array('value'=>'value')) |
| 639 | - ->where('name=?',$element); |
|
| 639 | + ->where('name=?', $element); |
|
| 640 | 640 | $return_row=$db->fetchRow($query); |
| 641 | - if ($return_row==null) // value does not exists |
|
| 641 | + if ($return_row == null) // value does not exists |
|
| 642 | 642 | { |
| 643 | 643 | $default=$this->getModuleConfig()->getDBConfigDefaults(); |
| 644 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 644 | + if (!isset($default[$element])) return null; // no default and not value |
|
| 645 | 645 | |
| 646 | - $this->addDBConfigValue($element,$default[$element]); |
|
| 646 | + $this->addDBConfigValue($element, $default[$element]); |
|
| 647 | 647 | return $default[$element]; |
| 648 | 648 | } |
| 649 | 649 | if ($return_row->value == null) // value id empty |
| 650 | 650 | { |
| 651 | 651 | $default=$this->getModuleConfig()->getDBConfigDefaults(); |
| 652 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 653 | - $this->setDBConfigValue($element,$default[$element]); |
|
| 652 | + if (!isset($default[$element])) return null; // no default and not value |
|
| 653 | + $this->setDBConfigValue($element, $default[$element]); |
|
| 654 | 654 | return $default[$element]; |
| 655 | 655 | } |
| 656 | 656 | return $return_row->value; |
@@ -659,10 +659,10 @@ discard block |
||
| 659 | 659 | /** add configuration value |
| 660 | 660 | * @param name value |
| 661 | 661 | */ |
| 662 | - protected function addDBConfigValue($element,$value) |
|
| 662 | + protected function addDBConfigValue($element, $value) |
|
| 663 | 663 | { |
| 664 | 664 | |
| 665 | - $db = $this->getDb()->getConnection(); |
|
| 665 | + $db=$this->getDb()->getConnection(); |
|
| 666 | 666 | |
| 667 | 667 | $query=$db->insert( |
| 668 | 668 | $this->getModuleConfig()->getDbConfigTableName(), |
@@ -677,10 +677,10 @@ discard block |
||
| 677 | 677 | /** set configuration value |
| 678 | 678 | * @param name value |
| 679 | 679 | */ |
| 680 | - protected function setDBConfigValue($element,$value) |
|
| 680 | + protected function setDBConfigValue($element, $value) |
|
| 681 | 681 | { |
| 682 | 682 | |
| 683 | - $db = $this->getDb()->getConnection(); |
|
| 683 | + $db=$this->getDb()->getConnection(); |
|
| 684 | 684 | $query=$db->update( |
| 685 | 685 | $this->getModuleConfig()->getDbConfigTableName(), |
| 686 | 686 | array('value'=>$value), |
@@ -695,10 +695,10 @@ discard block |
||
| 695 | 695 | protected function isDirectorInstalled() |
| 696 | 696 | { |
| 697 | 697 | $output=array(); |
| 698 | - exec('icingacli module list',$output); |
|
| 698 | + exec('icingacli module list', $output); |
|
| 699 | 699 | foreach ($output as $line) |
| 700 | 700 | { |
| 701 | - if (preg_match('/^director .*enabled/',$line)) |
|
| 701 | + if (preg_match('/^director .*enabled/', $line)) |
|
| 702 | 702 | { |
| 703 | 703 | return true; |
| 704 | 704 | } |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | $this->checkReadPermission(); |
| 24 | 24 | $this->prepareTabs()->activate('status'); |
| 25 | 25 | |
| 26 | - $db = $this->getDb(); |
|
| 26 | + $db=$this->getDb(); |
|
| 27 | 27 | $this->getHandlerListTable()->setConnection($db); |
| 28 | 28 | $this->getHandlerListTable()->setMibloader($this->getMIB()); |
| 29 | 29 | // Apply pagination limits |
| 30 | - $this->view->table=$this->applyPaginationLimits($this->getHandlerListTable(),$this->getModuleConfig()->itemListDisplay()); |
|
| 30 | + $this->view->table=$this->applyPaginationLimits($this->getHandlerListTable(), $this->getModuleConfig()->itemListDisplay()); |
|
| 31 | 31 | |
| 32 | 32 | // Set Filter |
| 33 | - $this->view->filterEditor = $this->getHandlerListTable()->getFilterEditor($this->getRequest()); |
|
| 33 | + $this->view->filterEditor=$this->getHandlerListTable()->getFilterEditor($this->getRequest()); |
|
| 34 | 34 | |
| 35 | 35 | //$this->displayExitError('Handler/indexAction','Not implemented'); |
| 36 | 36 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function testruleAction() |
| 41 | 41 | { |
| 42 | 42 | $this->checkReadPermission(); |
| 43 | - $this->getTabs()->add('get',array( |
|
| 43 | + $this->getTabs()->add('get', array( |
|
| 44 | 44 | 'active' => true, |
| 45 | 45 | 'label' => $this->translate('Test Rule'), |
| 46 | 46 | 'url' => Url::fromRequest() |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | if ($this->params->get('rule') !== null) |
| 52 | 52 | { |
| 53 | - $this->view->rule= $this->params->get('rule'); |
|
| 53 | + $this->view->rule=$this->params->get('rule'); |
|
| 54 | 54 | } |
| 55 | 55 | else |
| 56 | 56 | { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | $this->checkConfigPermission(); |
| 68 | 68 | // set up tab |
| 69 | - $this->getTabs()->add('get',array( |
|
| 69 | + $this->getTabs()->add('get', array( |
|
| 70 | 70 | 'active' => true, |
| 71 | 71 | 'label' => $this->translate('Add handler'), |
| 72 | 72 | 'url' => Url::fromRequest() |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | catch (Exception $e) |
| 118 | 118 | { |
| 119 | - $this->displayExitError('Add handler : get host by IP/Name ',$e->getMessage()); |
|
| 119 | + $this->displayExitError('Add handler : get host by IP/Name ', $e->getMessage()); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | // if one unique host found -> put id text input |
| 124 | - if (count($hosts)==1) { |
|
| 124 | + if (count($hosts) == 1) { |
|
| 125 | 125 | $this->view->hostname=$hosts[0]->name; |
| 126 | 126 | //$hostid=$hosts[0]->id; |
| 127 | 127 | // Tell JS to get services when page is loaded |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | else |
| 132 | 132 | { |
| 133 | - foreach($hosts as $key=>$val) |
|
| 133 | + foreach ($hosts as $key=>$val) |
|
| 134 | 134 | { |
| 135 | - array_push($this->view->hostlist,$hosts[$key]->name); |
|
| 135 | + array_push($this->view->hostlist, $hosts[$key]->name); |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
@@ -171,18 +171,18 @@ discard block |
||
| 171 | 171 | $currentObjectTypeEnum |
| 172 | 172 | ); |
| 173 | 173 | $oid_index++; |
| 174 | - array_push($this->view->objectList,$currentObject); |
|
| 174 | + array_push($this->view->objectList, $currentObject); |
|
| 175 | 175 | // set currrent object to null in allObjects |
| 176 | 176 | if (isset($allObjects[$val->oid])) |
| 177 | 177 | { |
| 178 | 178 | $allObjects[$val->oid]=null; |
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | - if ($allObjects!=null) // in case trap doesn't have objects or is not resolved |
|
| 181 | + if ($allObjects != null) // in case trap doesn't have objects or is not resolved |
|
| 182 | 182 | { |
| 183 | 183 | foreach ($allObjects as $key => $val) |
| 184 | 184 | { |
| 185 | - if ($val==null) { continue; } |
|
| 185 | + if ($val == null) { continue; } |
|
| 186 | 186 | array_push($this->view->objectList, array( |
| 187 | 187 | $oid_index, |
| 188 | 188 | $key, |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $this->view->setRuleMatch=$ruleDetail->action_match; |
| 217 | 217 | $this->view->setRuleNoMatch=$ruleDetail->action_nomatch; |
| 218 | 218 | $this->view->hostgroupname=$ruleDetail->host_group_name; |
| 219 | - $this->view->modified=gmdate("Y-m-d\TH:i:s\Z",$ruleDetail->modified); |
|
| 219 | + $this->view->modified=gmdate("Y-m-d\TH:i:s\Z", $ruleDetail->modified); |
|
| 220 | 220 | $this->view->modifier=$ruleDetail->modifier; |
| 221 | 221 | |
| 222 | 222 | // Warning message if host/service don't exists anymore |
@@ -227,9 +227,9 @@ discard block |
||
| 227 | 227 | // Check if hostname still exists |
| 228 | 228 | $host_get=$this->getHostByName($this->view->hostname); |
| 229 | 229 | |
| 230 | - if (count($host_get)==0) |
|
| 230 | + if (count($host_get) == 0) |
|
| 231 | 231 | { |
| 232 | - $this->view->warning_message='Host '.$this->view->hostname. ' doesn\'t exists anymore'; |
|
| 232 | + $this->view->warning_message='Host '.$this->view->hostname.' doesn\'t exists anymore'; |
|
| 233 | 233 | $this->view->serviceGet=false; |
| 234 | 234 | } |
| 235 | 235 | else |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | // Tell JS to get services when page is loaded |
| 238 | 238 | $this->view->serviceGet=true; |
| 239 | 239 | // get service id for form to set : |
| 240 | - $serviceID=$this->getServiceIDByName($this->view->hostname,$ruleDetail->service_name); |
|
| 241 | - if (count($serviceID) ==0) |
|
| 240 | + $serviceID=$this->getServiceIDByName($this->view->hostname, $ruleDetail->service_name); |
|
| 241 | + if (count($serviceID) == 0) |
|
| 242 | 242 | { |
| 243 | - $this->view->warning_message=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
|
| 243 | + $this->view->warning_message=' Service '.$ruleDetail->service_name.' doesn\'t exists anymore'; |
|
| 244 | 244 | } |
| 245 | 245 | else |
| 246 | 246 | { |
@@ -253,9 +253,9 @@ discard block |
||
| 253 | 253 | $this->view->selectGroup=true; |
| 254 | 254 | // Check if groupe exists |
| 255 | 255 | $group_get=$this->getHostGroupByName($this->view->hostgroupname); |
| 256 | - if (count($group_get)==0) |
|
| 256 | + if (count($group_get) == 0) |
|
| 257 | 257 | { |
| 258 | - $this->view->warning_message='HostGroup '.$this->view->hostgroupname. ' doesn\'t exists anymore'; |
|
| 258 | + $this->view->warning_message='HostGroup '.$this->view->hostgroupname.' doesn\'t exists anymore'; |
|
| 259 | 259 | $this->view->serviceGroupGet=false; |
| 260 | 260 | } |
| 261 | 261 | else |
@@ -273,9 +273,9 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | // Tell JS to get services when page is loaded |
| 275 | 275 | $this->view->serviceGroupGet=true; |
| 276 | - if ($foundGrpService==0) |
|
| 276 | + if ($foundGrpService == 0) |
|
| 277 | 277 | { |
| 278 | - $this->view->warning_message.=' Service '.$ruleDetail->service_name. ' doesn\'t exists anymore'; |
|
| 278 | + $this->view->warning_message.=' Service '.$ruleDetail->service_name.' doesn\'t exists anymore'; |
|
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | 281 | } |
@@ -295,8 +295,8 @@ discard block |
||
| 295 | 295 | $index=1; |
| 296 | 296 | // check in display & rule for : OID(<oid>) |
| 297 | 297 | $matches=array(); |
| 298 | - while ( preg_match('/_OID\(([\.0-9]+)\)/',$display,$matches) || |
|
| 299 | - preg_match('/_OID\(([\.0-9]+)\)/',$rule,$matches)) |
|
| 298 | + while (preg_match('/_OID\(([\.0-9]+)\)/', $display, $matches) || |
|
| 299 | + preg_match('/_OID\(([\.0-9]+)\)/', $rule, $matches)) |
|
| 300 | 300 | { |
| 301 | 301 | $curOid=$matches[1]; |
| 302 | 302 | if (($object=$this->getMIB()->translateOID($curOid)) != null) |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | 'not found' |
| 323 | 323 | )); |
| 324 | 324 | } |
| 325 | - $display=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$display); |
|
| 326 | - $rule=preg_replace('/_OID\('.$curOid.'\)/','\$'.$index.'\$',$rule); |
|
| 325 | + $display=preg_replace('/_OID\('.$curOid.'\)/', '\$'.$index.'\$', $display); |
|
| 326 | + $rule=preg_replace('/_OID\('.$curOid.'\)/', '\$'.$index.'\$', $rule); |
|
| 327 | 327 | $index++; |
| 328 | 328 | } |
| 329 | 329 | // set display |
@@ -345,26 +345,26 @@ discard block |
||
| 345 | 345 | |
| 346 | 346 | $params=array( |
| 347 | 347 | // id (also db) => array('post' => post id, 'val' => default val, 'db' => send to table) |
| 348 | - 'hostgroup' => array('post' => 'hostgroup','db'=>false), |
|
| 349 | - 'db_rule' => array('post' => 'db_rule','db'=>false), |
|
| 350 | - 'hostid' => array('post' => 'hostid','db'=>false), |
|
| 351 | - 'host_name' => array('post' => 'hostname','val' => null,'db'=>true), |
|
| 352 | - 'host_group_name'=> array('post' => null,'val' => null,'db'=>true), |
|
| 353 | - 'serviceid' => array('post' => 'serviceid','db'=>false), |
|
| 354 | - 'service_name' => array('post' => 'serviceName','db'=>true), |
|
| 355 | - 'trap_oid' => array('post' => 'oid','db'=>true), |
|
| 356 | - 'revert_ok' => array('post' => 'revertOK','val' => 0,'db'=>true), |
|
| 357 | - 'display' => array('post' => 'display','val' => '','db'=>true), |
|
| 358 | - 'rule' => array('post' => 'rule','val' => '','db'=>true), |
|
| 359 | - 'action_match' => array('post' => 'ruleMatch','val' => -1,'db'=>true), |
|
| 360 | - 'action_nomatch'=> array('post' => 'ruleNoMatch','val' => -1,'db'=>true), |
|
| 361 | - 'ip4' => array('post' => null,'val' => null,'db'=>true), |
|
| 362 | - 'ip6' => array('post' => null,'val' => null,'db'=>true), |
|
| 363 | - 'action_form' => array('post' => 'action_form','db'=>false) |
|
| 348 | + 'hostgroup' => array('post' => 'hostgroup', 'db'=>false), |
|
| 349 | + 'db_rule' => array('post' => 'db_rule', 'db'=>false), |
|
| 350 | + 'hostid' => array('post' => 'hostid', 'db'=>false), |
|
| 351 | + 'host_name' => array('post' => 'hostname', 'val' => null, 'db'=>true), |
|
| 352 | + 'host_group_name'=> array('post' => null, 'val' => null, 'db'=>true), |
|
| 353 | + 'serviceid' => array('post' => 'serviceid', 'db'=>false), |
|
| 354 | + 'service_name' => array('post' => 'serviceName', 'db'=>true), |
|
| 355 | + 'trap_oid' => array('post' => 'oid', 'db'=>true), |
|
| 356 | + 'revert_ok' => array('post' => 'revertOK', 'val' => 0, 'db'=>true), |
|
| 357 | + 'display' => array('post' => 'display', 'val' => '', 'db'=>true), |
|
| 358 | + 'rule' => array('post' => 'rule', 'val' => '', 'db'=>true), |
|
| 359 | + 'action_match' => array('post' => 'ruleMatch', 'val' => -1, 'db'=>true), |
|
| 360 | + 'action_nomatch'=> array('post' => 'ruleNoMatch', 'val' => -1, 'db'=>true), |
|
| 361 | + 'ip4' => array('post' => null, 'val' => null, 'db'=>true), |
|
| 362 | + 'ip6' => array('post' => null, 'val' => null, 'db'=>true), |
|
| 363 | + 'action_form' => array('post' => 'action_form', 'db'=>false) |
|
| 364 | 364 | ); |
| 365 | 365 | |
| 366 | 366 | if (isset($postData[$params['action_form']['post']]) |
| 367 | - && $postData[$params['action_form']['post']] == 'delete' ) |
|
| 367 | + && $postData[$params['action_form']['post']] == 'delete') |
|
| 368 | 368 | { |
| 369 | 369 | try |
| 370 | 370 | { |
@@ -384,16 +384,16 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | foreach (array_keys($params) as $key) |
| 386 | 386 | { |
| 387 | - if ($params[$key]['post']==null) continue; // data not sent in post vars |
|
| 388 | - if (! isset($postData[$params[$key]['post']])) |
|
| 387 | + if ($params[$key]['post'] == null) continue; // data not sent in post vars |
|
| 388 | + if (!isset($postData[$params[$key]['post']])) |
|
| 389 | 389 | { |
| 390 | 390 | // should not happen as the js checks data |
| 391 | - $this->_helper->json(array('status'=>'No ' . $key)); |
|
| 391 | + $this->_helper->json(array('status'=>'No '.$key)); |
|
| 392 | 392 | } |
| 393 | 393 | else |
| 394 | 394 | { |
| 395 | 395 | $data=$postData[$params[$key]['post']]; |
| 396 | - if ($data!=null && $data !="") |
|
| 396 | + if ($data != null && $data != "") |
|
| 397 | 397 | { |
| 398 | 398 | $params[$key]['val']=$postData[$params[$key]['post']]; |
| 399 | 399 | } |
@@ -402,8 +402,8 @@ discard block |
||
| 402 | 402 | |
| 403 | 403 | try |
| 404 | 404 | { |
| 405 | - $isHostGroup=($params['hostgroup']['val'] == 1)?true:false; |
|
| 406 | - if (! $isHostGroup ) |
|
| 405 | + $isHostGroup=($params['hostgroup']['val'] == 1) ?true:false; |
|
| 406 | + if (!$isHostGroup) |
|
| 407 | 407 | { // checks if selection by host |
| 408 | 408 | $hostAddr=$this->getHostInfoByID($params['hostid']['val']); |
| 409 | 409 | $params['ip4']['val']=$hostAddr->ip4; |
@@ -430,25 +430,25 @@ discard block |
||
| 430 | 430 | return; |
| 431 | 431 | } |
| 432 | 432 | // Put param in correct column (group_name) |
| 433 | - $params['host_group_name']['val'] = $params['host_name']['val']; |
|
| 433 | + $params['host_group_name']['val']=$params['host_name']['val']; |
|
| 434 | 434 | $params['host_name']['val']=null; |
| 435 | 435 | } |
| 436 | 436 | $dbparams=array(); |
| 437 | 437 | foreach ($params as $key=>$val) |
| 438 | 438 | { |
| 439 | - if ($val['db']==true ) |
|
| 439 | + if ($val['db'] == true) |
|
| 440 | 440 | { |
| 441 | - $dbparams[$key] = $val['val']; |
|
| 441 | + $dbparams[$key]=$val['val']; |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | // echo '<br>'; print_r($dbparams);echo '<br>'; |
| 445 | - if ($params['db_rule']['val'] == -1 ) |
|
| 445 | + if ($params['db_rule']['val'] == -1) |
|
| 446 | 446 | { |
| 447 | 447 | $ruleID=$this->addHandlerRule($dbparams); |
| 448 | 448 | } |
| 449 | 449 | else |
| 450 | 450 | { |
| 451 | - $this->updateHandlerRule($dbparams,$params['db_rule']['val']); |
|
| 451 | + $this->updateHandlerRule($dbparams, $params['db_rule']['val']); |
|
| 452 | 452 | $ruleID=$params['db_rule']['val']; |
| 453 | 453 | } |
| 454 | 454 | } |
@@ -467,10 +467,10 @@ discard block |
||
| 467 | 467 | */ |
| 468 | 468 | protected function getTrapDetail($trapid) |
| 469 | 469 | { |
| 470 | - if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id'); } |
|
| 470 | + if (!preg_match('/^[0-9]+$/', $trapid)) { throw new Exception('Invalid id'); } |
|
| 471 | 471 | $queryArray=$this->getModuleConfig()->trapDetailQuery(); |
| 472 | 472 | |
| 473 | - $db = $this->getDb()->getConnection(); |
|
| 473 | + $db=$this->getDb()->getConnection(); |
|
| 474 | 474 | // *************** Get main data |
| 475 | 475 | // extract columns and titles; |
| 476 | 476 | $elmts=NULL; |
@@ -479,15 +479,15 @@ discard block |
||
| 479 | 479 | } |
| 480 | 480 | try |
| 481 | 481 | { |
| 482 | - $query = $db->select() |
|
| 483 | - ->from($this->getModuleConfig()->getTrapTableName(),$elmts) |
|
| 484 | - ->where('id=?',$trapid); |
|
| 482 | + $query=$db->select() |
|
| 483 | + ->from($this->getModuleConfig()->getTrapTableName(), $elmts) |
|
| 484 | + ->where('id=?', $trapid); |
|
| 485 | 485 | $trapDetail=$db->fetchRow($query); |
| 486 | - if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid); |
|
| 486 | + if ($trapDetail == null) throw new Exception('No traps was found with id = '.$trapid); |
|
| 487 | 487 | } |
| 488 | 488 | catch (Exception $e) |
| 489 | 489 | { |
| 490 | - $this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail,true),$e->getMessage()); |
|
| 490 | + $this->displayExitError('Add handler : get trap detail returning : '.print_r($trapDetail, true), $e->getMessage()); |
|
| 491 | 491 | return; |
| 492 | 492 | } |
| 493 | 493 | |
@@ -501,10 +501,10 @@ discard block |
||
| 501 | 501 | */ |
| 502 | 502 | protected function getTrapobjects($trapid) |
| 503 | 503 | { |
| 504 | - if (!preg_match('/^[0-9]+$/',$trapid)) { throw new Exception('Invalid id'); } |
|
| 504 | + if (!preg_match('/^[0-9]+$/', $trapid)) { throw new Exception('Invalid id'); } |
|
| 505 | 505 | $queryArrayData=$this->getModuleConfig()->trapDataDetailQuery(); |
| 506 | 506 | |
| 507 | - $db = $this->getDb()->getConnection(); |
|
| 507 | + $db=$this->getDb()->getConnection(); |
|
| 508 | 508 | // *************** Get object data |
| 509 | 509 | // extract columns and titles; |
| 510 | 510 | $data_elmts=NULL; |
@@ -513,15 +513,15 @@ discard block |
||
| 513 | 513 | } |
| 514 | 514 | try |
| 515 | 515 | { |
| 516 | - $query = $db->select() |
|
| 517 | - ->from($this->moduleConfig->getTrapDataTableName(),$data_elmts) |
|
| 518 | - ->where('trap_id=?',$trapid); |
|
| 516 | + $query=$db->select() |
|
| 517 | + ->from($this->moduleConfig->getTrapDataTableName(), $data_elmts) |
|
| 518 | + ->where('trap_id=?', $trapid); |
|
| 519 | 519 | $trapDetail=$db->fetchAll($query); |
| 520 | 520 | // if ( $trapDetail == null ) throw new Exception('No traps was found with id = '.$trapid); |
| 521 | 521 | } |
| 522 | 522 | catch (Exception $e) |
| 523 | 523 | { |
| 524 | - $this->displayExitError('Add handler : get trap data detail : ',$e->getMessage()); |
|
| 524 | + $this->displayExitError('Add handler : get trap data detail : ', $e->getMessage()); |
|
| 525 | 525 | return array(); |
| 526 | 526 | } |
| 527 | 527 | |
@@ -534,22 +534,22 @@ discard block |
||
| 534 | 534 | */ |
| 535 | 535 | protected function getRuleDetail($ruleid) |
| 536 | 536 | { |
| 537 | - if (!preg_match('/^[0-9]+$/',$ruleid)) { throw new Exception('Invalid id'); } |
|
| 537 | + if (!preg_match('/^[0-9]+$/', $ruleid)) { throw new Exception('Invalid id'); } |
|
| 538 | 538 | $queryArray=$this->getModuleConfig()->ruleDetailQuery(); |
| 539 | 539 | |
| 540 | - $db = $this->getDb()->getConnection(); |
|
| 540 | + $db=$this->getDb()->getConnection(); |
|
| 541 | 541 | // *************** Get main data |
| 542 | 542 | try |
| 543 | 543 | { |
| 544 | - $query = $db->select() |
|
| 545 | - ->from($this->getModuleConfig()->getTrapRuleName(),$queryArray) |
|
| 546 | - ->where('id=?',$ruleid); |
|
| 544 | + $query=$db->select() |
|
| 545 | + ->from($this->getModuleConfig()->getTrapRuleName(), $queryArray) |
|
| 546 | + ->where('id=?', $ruleid); |
|
| 547 | 547 | $ruleDetail=$db->fetchRow($query); |
| 548 | - if ( $ruleDetail == null ) throw new Exception('No rule was found with id = '.$ruleid); |
|
| 548 | + if ($ruleDetail == null) throw new Exception('No rule was found with id = '.$ruleid); |
|
| 549 | 549 | } |
| 550 | 550 | catch (Exception $e) |
| 551 | 551 | { |
| 552 | - $this->displayExitError('Update handler : get rule detail',$e->getMessage()); |
|
| 552 | + $this->displayExitError('Update handler : get rule detail', $e->getMessage()); |
|
| 553 | 553 | return array(); |
| 554 | 554 | } |
| 555 | 555 | |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | { |
| 564 | 564 | return $this->getTabs()->add('status', array( |
| 565 | 565 | 'label' => $this->translate('Traps'), |
| 566 | - 'url' => $this->getModuleConfig()->urlPath() . '/handler') |
|
| 566 | + 'url' => $this->getModuleConfig()->urlPath().'/handler') |
|
| 567 | 567 | ); |
| 568 | 568 | } |
| 569 | 569 | |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - $retHosts=array('status'=>'OK','hosts' => array()); |
|
| 30 | + $retHosts=array('status'=>'OK', 'hosts' => array()); |
|
| 31 | 31 | |
| 32 | 32 | $hosts=$this->getHostByIP($hostFilter); |
| 33 | 33 | foreach ($hosts as $val) |
| 34 | 34 | { |
| 35 | - array_push($retHosts['hosts'],$val->name); |
|
| 35 | + array_push($retHosts['hosts'], $val->name); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $this->_helper->json($retHosts); |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | return; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - $retHosts=array('status'=>'OK','hosts' => array()); |
|
| 58 | + $retHosts=array('status'=>'OK', 'hosts' => array()); |
|
| 59 | 59 | |
| 60 | 60 | $hosts=$this->getHostGroupByName($hostFilter); |
| 61 | 61 | foreach ($hosts as $val) |
| 62 | 62 | { |
| 63 | - array_push($retHosts['hosts'],$val->name); |
|
| 63 | + array_push($retHosts['hosts'], $val->name); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | $this->_helper->json($retHosts); |
@@ -82,31 +82,31 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | else |
| 84 | 84 | { |
| 85 | - $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
|
| 85 | + $this->_helper->json(array('status'=>'No Hosts', 'hostid' => -1)); |
|
| 86 | 86 | return; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $hostArray=$this->getHostByName($host); |
| 90 | 90 | if (count($hostArray) > 1) |
| 91 | 91 | { |
| 92 | - $this->_helper->json(array('status'=>'More than one host matches','hostid' => -1)); |
|
| 92 | + $this->_helper->json(array('status'=>'More than one host matches', 'hostid' => -1)); |
|
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | else if (count($hostArray) == 0) |
| 96 | 96 | { |
| 97 | - $this->_helper->json(array('status'=>'No host matches','hostid' => -1)); |
|
| 97 | + $this->_helper->json(array('status'=>'No host matches', 'hostid' => -1)); |
|
| 98 | 98 | return; |
| 99 | 99 | } |
| 100 | 100 | $services=$this->getServicesByHostid($hostArray[0]->id); |
| 101 | 101 | if (count($services) < 1) |
| 102 | 102 | { |
| 103 | - $this->_helper->json(array('status'=>'No services found for host','hostid' => $hostArray[0]->id)); |
|
| 103 | + $this->_helper->json(array('status'=>'No services found for host', 'hostid' => $hostArray[0]->id)); |
|
| 104 | 104 | return; |
| 105 | 105 | } |
| 106 | - $retServices=array('status'=>'OK','services' => array(),'hostid' => $hostArray[0]->id); |
|
| 106 | + $retServices=array('status'=>'OK', 'services' => array(), 'hostid' => $hostArray[0]->id); |
|
| 107 | 107 | foreach ($services as $val) |
| 108 | 108 | { |
| 109 | - array_push($retServices['services'],array($val->id , $val->name)); |
|
| 109 | + array_push($retServices['services'], array($val->id, $val->name)); |
|
| 110 | 110 | } |
| 111 | 111 | $this->_helper->json($retServices); |
| 112 | 112 | } |
@@ -126,28 +126,28 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | else |
| 128 | 128 | { |
| 129 | - $this->_helper->json(array('status'=>'No Hosts','hostid' => -1)); |
|
| 129 | + $this->_helper->json(array('status'=>'No Hosts', 'hostid' => -1)); |
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | $hostArray=$this->getHostGroupByName($host); |
| 134 | 134 | if (count($hostArray) > 1) |
| 135 | 135 | { |
| 136 | - $this->_helper->json(array('status'=>'More than one hostgroup matches','hostid' => -1)); |
|
| 136 | + $this->_helper->json(array('status'=>'More than one hostgroup matches', 'hostid' => -1)); |
|
| 137 | 137 | return; |
| 138 | 138 | } |
| 139 | 139 | else if (count($hostArray) == 0) |
| 140 | 140 | { |
| 141 | - $this->_helper->json(array('status'=>'No hostgroup matches','hostid' => -1)); |
|
| 141 | + $this->_helper->json(array('status'=>'No hostgroup matches', 'hostid' => -1)); |
|
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | $services=$this->getServicesByHostGroupid($hostArray[0]->id); |
| 145 | 145 | if (count($services) < 1) |
| 146 | 146 | { |
| 147 | - $this->_helper->json(array('status'=>'No services found for hostgroup','hostid' => $hostArray[0]->id)); |
|
| 147 | + $this->_helper->json(array('status'=>'No services found for hostgroup', 'hostid' => $hostArray[0]->id)); |
|
| 148 | 148 | return; |
| 149 | 149 | } |
| 150 | - $retServices=array('status'=>'OK','services' => $services,'hostid' => $hostArray[0]->id); |
|
| 150 | + $retServices=array('status'=>'OK', 'services' => $services, 'hostid' => $hostArray[0]->id); |
|
| 151 | 151 | |
| 152 | 152 | $this->_helper->json($retServices); |
| 153 | 153 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | try |
| 173 | 173 | { |
| 174 | 174 | $traplist=$this->getMIB()->getTrapList($mib); |
| 175 | - $retTraps=array('status'=>'OK','traps' => $traplist); |
|
| 175 | + $retTraps=array('status'=>'OK', 'traps' => $traplist); |
|
| 176 | 176 | } |
| 177 | 177 | catch (Exception $e) |
| 178 | 178 | { |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | try |
| 202 | 202 | { |
| 203 | 203 | $objectlist=$this->getMIB()->getObjectList($trap); |
| 204 | - $retObjects=array('status'=>'OK','objects' => $objectlist); |
|
| 204 | + $retObjects=array('status'=>'OK', 'objects' => $objectlist); |
|
| 205 | 205 | } |
| 206 | 206 | catch (Exception $e) |
| 207 | 207 | { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | if (isset($postData['days'])) |
| 279 | 279 | { |
| 280 | 280 | $days=$postData['days']; |
| 281 | - if (!preg_match('/^[0-9]+$/',$days)) |
|
| 281 | + if (!preg_match('/^[0-9]+$/', $days)) |
|
| 282 | 282 | { |
| 283 | 283 | $this->_helper->json(array('status'=>'invalid days : '.$days)); |
| 284 | 284 | return; |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | if (isset($postData['action'])) |
| 293 | 293 | { |
| 294 | 294 | $action=$postData['action']; |
| 295 | - if ($action != 'save' && $action !='execute') |
|
| 295 | + if ($action != 'save' && $action != 'execute') |
|
| 296 | 296 | { |
| 297 | 297 | $this->_helper->json(array('status'=>'unknown action '.$action)); |
| 298 | 298 | return; |
@@ -307,11 +307,11 @@ discard block |
||
| 307 | 307 | { |
| 308 | 308 | try |
| 309 | 309 | { |
| 310 | - $this->setDBConfigValue('db_remove_days',$days); |
|
| 310 | + $this->setDBConfigValue('db_remove_days', $days); |
|
| 311 | 311 | } |
| 312 | 312 | catch (Exception $e) |
| 313 | 313 | { |
| 314 | - $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
|
| 314 | + $this->_helper->json(array('status'=>'Save error : '.$e->getMessage())); |
|
| 315 | 315 | return; |
| 316 | 316 | } |
| 317 | 317 | $this->_helper->json(array('status'=>'OK')); |
@@ -321,16 +321,16 @@ discard block |
||
| 321 | 321 | { |
| 322 | 322 | try |
| 323 | 323 | { |
| 324 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 324 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 325 | 325 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 326 | 326 | $debug_level=4; |
| 327 | - $Trap = new Trap($icingaweb2_etc); |
|
| 328 | - $Trap->setLogging($debug_level,'syslog'); |
|
| 327 | + $Trap=new Trap($icingaweb2_etc); |
|
| 328 | + $Trap->setLogging($debug_level, 'syslog'); |
|
| 329 | 329 | $Trap->eraseOldTraps($days); |
| 330 | 330 | } |
| 331 | 331 | catch (Exception $e) |
| 332 | 332 | { |
| 333 | - $this->_helper->json(array('status'=>'execute error : '.$e->getMessage() )); |
|
| 333 | + $this->_helper->json(array('status'=>'execute error : '.$e->getMessage())); |
|
| 334 | 334 | return; |
| 335 | 335 | } |
| 336 | 336 | $this->_helper->json(array('status'=>'OK')); |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | if (isset($postData['file'])) |
| 365 | 365 | { |
| 366 | 366 | $file=$postData['file']; |
| 367 | - $fileHandler=@fopen($file,'w'); |
|
| 367 | + $fileHandler=@fopen($file, 'w'); |
|
| 368 | 368 | if ($fileHandler == false) |
| 369 | 369 | { // File os note writabe / cannot create |
| 370 | 370 | $this->_helper->json(array('status'=>'File not writable : '.$file)); |
@@ -396,13 +396,13 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | try |
| 398 | 398 | { |
| 399 | - $this->setDBConfigValue('log_destination',$destination); |
|
| 400 | - $this->setDBConfigValue('log_file',$file); |
|
| 401 | - $this->setDBConfigValue('log_level',$level); |
|
| 399 | + $this->setDBConfigValue('log_destination', $destination); |
|
| 400 | + $this->setDBConfigValue('log_file', $file); |
|
| 401 | + $this->setDBConfigValue('log_level', $level); |
|
| 402 | 402 | } |
| 403 | 403 | catch (Exception $e) |
| 404 | 404 | { |
| 405 | - $this->_helper->json(array('status'=>'Save error : '.$e->getMessage() )); |
|
| 405 | + $this->_helper->json(array('status'=>'Save error : '.$e->getMessage())); |
|
| 406 | 406 | return; |
| 407 | 407 | } |
| 408 | 408 | $this->_helper->json(array('status'=>'OK')); |
@@ -445,21 +445,21 @@ discard block |
||
| 445 | 445 | { |
| 446 | 446 | try |
| 447 | 447 | { |
| 448 | - require_once($this->Module()->getBaseDir() .'/bin/trap_class.php'); |
|
| 448 | + require_once($this->Module()->getBaseDir().'/bin/trap_class.php'); |
|
| 449 | 449 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 450 | - $Trap = new Trap($icingaweb2_etc); |
|
| 450 | + $Trap=new Trap($icingaweb2_etc); |
|
| 451 | 451 | // Cleanup spaces before eval |
| 452 | 452 | $rule=$Trap->eval_cleanup($rule); |
| 453 | 453 | // Eval |
| 454 | 454 | $item=0; |
| 455 | - $rule=$Trap->evaluation($rule,$item); |
|
| 455 | + $rule=$Trap->evaluation($rule, $item); |
|
| 456 | 456 | } |
| 457 | 457 | catch (Exception $e) |
| 458 | 458 | { |
| 459 | - $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage() )); |
|
| 459 | + $this->_helper->json(array('status'=>'Evaluation error : '.$e->getMessage())); |
|
| 460 | 460 | return; |
| 461 | 461 | } |
| 462 | - $return=($rule==true)?'true':'false'; |
|
| 462 | + $return=($rule == true) ? 'true' : 'false'; |
|
| 463 | 463 | $this->_helper->json(array('status'=>'OK', 'message' => $return)); |
| 464 | 464 | } |
| 465 | 465 | |
@@ -22,18 +22,18 @@ discard block |
||
| 22 | 22 | /************ Trapdb ***********/ |
| 23 | 23 | try |
| 24 | 24 | { |
| 25 | - $db = $this->getDb()->getConnection(); |
|
| 26 | - $query = $db->select()->from( |
|
| 25 | + $db=$this->getDb()->getConnection(); |
|
| 26 | + $query=$db->select()->from( |
|
| 27 | 27 | $this->getModuleConfig()->getTrapTableName(), |
| 28 | 28 | array('COUNT(*)') |
| 29 | 29 | ); |
| 30 | 30 | $this->view->trap_count=$db->fetchOne($query); |
| 31 | - $query = $db->select()->from( |
|
| 31 | + $query=$db->select()->from( |
|
| 32 | 32 | $this->getModuleConfig()->getTrapDataTableName(), |
| 33 | 33 | array('COUNT(*)') |
| 34 | 34 | ); |
| 35 | 35 | $this->view->trap_object_count=$db->fetchOne($query); |
| 36 | - $query = $db->select()->from( |
|
| 36 | + $query=$db->select()->from( |
|
| 37 | 37 | $this->getModuleConfig()->getTrapRuleName(), |
| 38 | 38 | array('COUNT(*)') |
| 39 | 39 | ); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | catch (Exception $e) |
| 46 | 46 | { |
| 47 | - $this->displayExitError('status',$e->getMessage()); |
|
| 47 | + $this->displayExitError('status', $e->getMessage()); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /*************** Log destination *******************/ |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | catch (Exception $e) |
| 61 | 61 | { |
| 62 | - $this->displayExitError('status',$e->getMessage()); |
|
| 62 | + $this->displayExitError('status', $e->getMessage()); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | if ($action == 'update_mib_db') |
| 86 | 86 | { // Do the update in background |
| 87 | 87 | $return=exec('icingacli trapdirector mib update --pid /tmp/trapdirector_update.pid'); |
| 88 | - if (preg_match('/OK/',$return)) |
|
| 88 | + if (preg_match('/OK/', $return)) |
|
| 89 | 89 | { |
| 90 | 90 | $this->_helper->json(array('status'=>'OK')); |
| 91 | 91 | } |
@@ -94,34 +94,34 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | if ($action == 'check_update') |
| 96 | 96 | { |
| 97 | - $file=@fopen('/tmp/trapdirector_update.pid','r'); |
|
| 97 | + $file=@fopen('/tmp/trapdirector_update.pid', 'r'); |
|
| 98 | 98 | if ($file == false) |
| 99 | 99 | { // process is dead |
| 100 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'Cannot open file')); |
|
| 100 | + $this->_helper->json(array('status'=>'tu quoque fili', 'err'=>'Cannot open file')); |
|
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | 103 | $pid=fgets($file); |
| 104 | 104 | $output=array(); |
| 105 | 105 | $retVal=0; |
| 106 | - exec('ps '.$pid,$output,$retVal); |
|
| 106 | + exec('ps '.$pid, $output, $retVal); |
|
| 107 | 107 | if ($retVal == 0) |
| 108 | 108 | { // process is alive |
| 109 | 109 | $this->_helper->json(array('status'=>'Alive and kicking')); |
| 110 | 110 | } |
| 111 | 111 | else |
| 112 | 112 | { // process is dead |
| 113 | - $this->_helper->json(array('status'=>'tu quoque fili','err'=>'no proc'.$pid)); |
|
| 113 | + $this->_helper->json(array('status'=>'tu quoque fili', 'err'=>'no proc'.$pid)); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | - $this->_helper->json(array('status'=>'ERR : no '.$action.' action possible' )); |
|
| 116 | + $this->_helper->json(array('status'=>'ERR : no '.$action.' action possible')); |
|
| 117 | 117 | } |
| 118 | 118 | /** Check for mib file UPLOAD */ |
| 119 | 119 | if (isset($_FILES['mibfile'])) |
| 120 | 120 | { |
| 121 | 121 | $name=$_FILES['mibfile']['name']; |
| 122 | - $DirConf=explode(':',$this->Config()->get('config', 'snmptranslate_dirs')); |
|
| 123 | - $destination = array_shift($DirConf) .'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
|
| 124 | - if (move_uploaded_file($_FILES['mibfile']['tmp_name'],$destination)===false) |
|
| 122 | + $DirConf=explode(':', $this->Config()->get('config', 'snmptranslate_dirs')); |
|
| 123 | + $destination=array_shift($DirConf).'/'.$name; //$this->Module()->getBaseDir() . "/mibs/$name"; |
|
| 124 | + if (move_uploaded_file($_FILES['mibfile']['tmp_name'], $destination) === false) |
|
| 125 | 125 | { |
| 126 | 126 | $this->view->uploadStatus='ERROR, file not loaded. Check mibs directory permission'; |
| 127 | 127 | } |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // snmptranslate tests |
| 137 | - $snmptranslate = $this->Config()->get('config', 'snmptranslate'); |
|
| 137 | + $snmptranslate=$this->Config()->get('config', 'snmptranslate'); |
|
| 138 | 138 | $this->view->snmptranslate_bin=$snmptranslate; |
| 139 | 139 | $this->view->snmptranslate_state='warn'; |
| 140 | - if (is_executable ( $snmptranslate )) |
|
| 140 | + if (is_executable($snmptranslate)) |
|
| 141 | 141 | { |
| 142 | - $translate=exec($snmptranslate . ' 1'); |
|
| 143 | - if (preg_match('/iso/',$translate)) |
|
| 142 | + $translate=exec($snmptranslate.' 1'); |
|
| 143 | + if (preg_match('/iso/', $translate)) |
|
| 144 | 144 | { |
| 145 | 145 | $this->view->snmptranslate='works fine'; |
| 146 | 146 | $this->view->snmptranslate_state='ok'; |
@@ -158,46 +158,46 @@ discard block |
||
| 158 | 158 | // mib database |
| 159 | 159 | |
| 160 | 160 | $this->view->mibDbCount=$this->getMIB()->countObjects(); |
| 161 | - $this->view->mibDbCountTrap=$this->getMIB()->countObjects(null,21); |
|
| 161 | + $this->view->mibDbCountTrap=$this->getMIB()->countObjects(null, 21); |
|
| 162 | 162 | |
| 163 | 163 | // mib dirs |
| 164 | 164 | $DirConf=$this->Config()->get('config', 'snmptranslate_dirs'); |
| 165 | - $dirArray=explode(':',$DirConf); |
|
| 165 | + $dirArray=explode(':', $DirConf); |
|
| 166 | 166 | |
| 167 | 167 | // Get base directories from net-snmp-config |
| 168 | 168 | $output=$matches=array(); |
| 169 | 169 | $retVal=0; |
| 170 | - $sysDirs=exec('net-snmp-config --default-mibdirs',$output,$retVal); |
|
| 171 | - if ($retVal==0) |
|
| 170 | + $sysDirs=exec('net-snmp-config --default-mibdirs', $output, $retVal); |
|
| 171 | + if ($retVal == 0) |
|
| 172 | 172 | { |
| 173 | - $dirArray=array_merge($dirArray,explode(':',$sysDirs)); |
|
| 173 | + $dirArray=array_merge($dirArray, explode(':', $sysDirs)); |
|
| 174 | 174 | } |
| 175 | 175 | else |
| 176 | 176 | { |
| 177 | - $translateOut=exec($this->Config()->get('config', 'snmptranslate') . ' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
|
| 178 | - if (preg_match('/MIBDIRS.*\'([^\']+)\'/',$translateOut,$matches)) |
|
| 177 | + $translateOut=exec($this->Config()->get('config', 'snmptranslate').' -Dinit_mib .1.3 2>&1 | grep MIBDIRS'); |
|
| 178 | + if (preg_match('/MIBDIRS.*\'([^\']+)\'/', $translateOut, $matches)) |
|
| 179 | 179 | { |
| 180 | - $dirArray=array_merge($dirArray,explode(':',$matches[1])); |
|
| 180 | + $dirArray=array_merge($dirArray, explode(':', $matches[1])); |
|
| 181 | 181 | } |
| 182 | 182 | else |
| 183 | 183 | { |
| 184 | - array_push($dirArray,'Install net-snmp-config to see system directories'); |
|
| 184 | + array_push($dirArray, 'Install net-snmp-config to see system directories'); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $this->view->dirArray=$dirArray; |
| 189 | 189 | |
| 190 | 190 | $output=null; |
| 191 | - foreach (explode(':',$DirConf) as $mibdir) |
|
| 191 | + foreach (explode(':', $DirConf) as $mibdir) |
|
| 192 | 192 | { |
| 193 | - exec('ls '.$mibdir.' | grep -v traplist.txt',$output); |
|
| 193 | + exec('ls '.$mibdir.' | grep -v traplist.txt', $output); |
|
| 194 | 194 | } |
| 195 | 195 | //$i=0;$listFiles='';while (isset($output[$i])) $listFiles.=$output[$i++]; |
| 196 | 196 | //$this->view->fileList=explode(' ',$listFiles); |
| 197 | 197 | $this->view->fileList=$output; |
| 198 | 198 | |
| 199 | 199 | // Zend form |
| 200 | - $this->view->form= new UploadForm(); |
|
| 200 | + $this->view->form=new UploadForm(); |
|
| 201 | 201 | //$this->view->form= new Form('upload-form'); |
| 202 | 202 | |
| 203 | 203 | |
@@ -221,18 +221,18 @@ discard block |
||
| 221 | 221 | $this->view->templateForm_output=''; |
| 222 | 222 | if (isset($postData['template_name']) && isset($postData['template_revert_time'])) |
| 223 | 223 | { |
| 224 | - $template_create = 'icingacli director service create --json \'{ "check_command": "dummy", '; |
|
| 225 | - $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", '; |
|
| 226 | - $template_create .= '"object_name": "'.$postData['template_name'].'", "object_type": "template", "retry_interval": "'.$postData['template_revert_time'].'"}\''; |
|
| 224 | + $template_create='icingacli director service create --json \'{ "check_command": "dummy", '; |
|
| 225 | + $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", '; |
|
| 226 | + $template_create.='"object_name": "'.$postData['template_name'].'", "object_type": "template", "retry_interval": "'.$postData['template_revert_time'].'"}\''; |
|
| 227 | 227 | $output=array(); |
| 228 | 228 | $ret_code=0; |
| 229 | - exec($template_create,$output,$ret_code); |
|
| 229 | + exec($template_create, $output, $ret_code); |
|
| 230 | 230 | if ($ret_code != 0) |
| 231 | 231 | { |
| 232 | - $this->displayExitError("Status -> Services","Error creating template : ".$output[0].'<br>Command was : '.$template_create); |
|
| 232 | + $this->displayExitError("Status -> Services", "Error creating template : ".$output[0].'<br>Command was : '.$template_create); |
|
| 233 | 233 | } |
| 234 | - exec('icingacli director config deploy',$output,$ret_code); |
|
| 235 | - $this->view->templateForm_output='Template '.$postData['template_name']. ' created'; |
|
| 234 | + exec('icingacli director config deploy', $output, $ret_code); |
|
| 235 | + $this->view->templateForm_output='Template '.$postData['template_name'].' created'; |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // template creation form |
@@ -245,13 +245,13 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | return $this->getTabs()->add('status', array( |
| 247 | 247 | 'label' => $this->translate('Status'), |
| 248 | - 'url' => $this->getModuleConfig()->urlPath() . '/status') |
|
| 248 | + 'url' => $this->getModuleConfig()->urlPath().'/status') |
|
| 249 | 249 | )->add('mib', array( |
| 250 | 250 | 'label' => $this->translate('MIB Management'), |
| 251 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/mib') |
|
| 251 | + 'url' => $this->getModuleConfig()->urlPath().'/status/mib') |
|
| 252 | 252 | )->add('services', array( |
| 253 | 253 | 'label' => $this->translate('Services management'), |
| 254 | - 'url' => $this->getModuleConfig()->urlPath() . '/status/services') |
|
| 254 | + 'url' => $this->getModuleConfig()->urlPath().'/status/services') |
|
| 255 | 255 | ); |
| 256 | 256 | } |
| 257 | 257 | } |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | // TODO : see if useless |
| 260 | 260 | class UploadForm extends Form |
| 261 | 261 | { |
| 262 | - public function __construct($options = null) |
|
| 262 | + public function __construct($options=null) |
|
| 263 | 263 | { |
| 264 | 264 | parent::__construct($options); |
| 265 | 265 | $this->addElements2(); |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | public function addElements2() |
| 269 | 269 | { |
| 270 | 270 | // File Input |
| 271 | - $file = new File('mib-file'); |
|
| 271 | + $file=new File('mib-file'); |
|
| 272 | 272 | $file->setLabel('Mib upload'); |
| 273 | 273 | //->setAttrib('multiple', null); |
| 274 | 274 | $this->addElement($file); |
| 275 | - $button = new Submit("upload",array('ignore'=>false)); |
|
| 276 | - $this->addElement($button);//->setIgnore(false); |
|
| 275 | + $button=new Submit("upload", array('ignore'=>false)); |
|
| 276 | + $this->addElement($button); //->setIgnore(false); |
|
| 277 | 277 | } |
| 278 | 278 | } |