@@ -10,22 +10,22 @@ |
||
| 10 | 10 | 'url' => 'settings' |
| 11 | 11 | )); |
| 12 | 12 | |
| 13 | -$section = $this->menuSection(N_('Traps'),array ( |
|
| 13 | +$section=$this->menuSection(N_('Traps'), array( |
|
| 14 | 14 | 'icon' => 'filter', |
| 15 | 15 | 'url' => 'trapdirector' |
| 16 | 16 | )); |
| 17 | 17 | |
| 18 | -$section->add(N_('Status & Mibs'),array( |
|
| 18 | +$section->add(N_('Status & Mibs'), array( |
|
| 19 | 19 | 'url' => 'trapdirector/status/', |
| 20 | 20 | 'permission' => 'trapdirector/view' |
| 21 | 21 | )); |
| 22 | 22 | |
| 23 | -$section->add(N_('Received'),array( |
|
| 23 | +$section->add(N_('Received'), array( |
|
| 24 | 24 | 'url' => 'trapdirector/received/', |
| 25 | 25 | 'permission' => 'trapdirector/view' |
| 26 | 26 | )); |
| 27 | 27 | |
| 28 | -$section->add(N_('Handlers'),array( |
|
| 28 | +$section->add(N_('Handlers'), array( |
|
| 29 | 29 | 'url' => 'trapdirector/handler/', |
| 30 | 30 | 'permission' => 'trapdirector/config' |
| 31 | 31 | )); |
@@ -24,21 +24,21 @@ |
||
| 24 | 24 | public function dbAction() |
| 25 | 25 | { |
| 26 | 26 | $db_prefix=$this->Config()->get('config', 'database_prefix'); |
| 27 | - $Config = new TrapModuleConfig($db_prefix); |
|
| 27 | + $Config=new TrapModuleConfig($db_prefix); |
|
| 28 | 28 | |
| 29 | 29 | try |
| 30 | 30 | { |
| 31 | 31 | |
| 32 | 32 | $dbresource=$this->Config()->get('config', 'database'); |
| 33 | - printf("DB name : %s\n",$dbresource); |
|
| 34 | - $dataBase = IcingaDbConnection::fromResourceName($dbresource)->getConnection(); |
|
| 33 | + printf("DB name : %s\n", $dbresource); |
|
| 34 | + $dataBase=IcingaDbConnection::fromResourceName($dbresource)->getConnection(); |
|
| 35 | 35 | |
| 36 | - $query = $dataBase->select()->from($Config->getTrapTableName(),array('COUNT(*)')); |
|
| 37 | - printf("Number of traps : %s\n", $dataBase->fetchOne($query) ); |
|
| 38 | - $query = $dataBase->select()->from($Config->getTrapDataTableName(),array('COUNT(*)')); |
|
| 39 | - printf("Number of trap objects : %s\n", $dataBase->fetchOne($query) ); |
|
| 40 | - $query = $dataBase->select()->from($Config->getTrapRuleName(),array('COUNT(*)')); |
|
| 41 | - printf("Number of rules : %s\n", $dataBase->fetchOne($query) ); |
|
| 36 | + $query=$dataBase->select()->from($Config->getTrapTableName(), array('COUNT(*)')); |
|
| 37 | + printf("Number of traps : %s\n", $dataBase->fetchOne($query)); |
|
| 38 | + $query=$dataBase->select()->from($Config->getTrapDataTableName(), array('COUNT(*)')); |
|
| 39 | + printf("Number of trap objects : %s\n", $dataBase->fetchOne($query)); |
|
| 40 | + $query=$dataBase->select()->from($Config->getTrapRuleName(), array('COUNT(*)')); |
|
| 41 | + printf("Number of rules : %s\n", $dataBase->fetchOne($query)); |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | catch (Exception $e) |
@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | public function rotateAction() |
| 31 | 31 | { |
| 32 | 32 | $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
| 33 | - require_once($module->getBaseDir() .'/bin/trap_class.php'); |
|
| 33 | + require_once($module->getBaseDir().'/bin/trap_class.php'); |
|
| 34 | 34 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 35 | 35 | $debug_level=2; |
| 36 | - $trap = new Trap($icingaweb2_etc); |
|
| 37 | - $trap->setLogging($debug_level,'display'); |
|
| 36 | + $trap=new Trap($icingaweb2_etc); |
|
| 37 | + $trap->setLogging($debug_level, 'display'); |
|
| 38 | 38 | try |
| 39 | 39 | { |
| 40 | - $days = $this->params->get('days', '<default>'); |
|
| 40 | + $days=$this->params->get('days', '<default>'); |
|
| 41 | 41 | echo $this->screen->colorize("Deleting traps older than $days days\n", 'lightblue'); |
| 42 | - if ($days=='<default>') |
|
| 42 | + if ($days == '<default>') |
|
| 43 | 43 | { |
| 44 | 44 | $trap->eraseOldTraps(); |
| 45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | catch (Exception $e) |
| 53 | 53 | { |
| 54 | - echo 'Error in updating : ' . $e->getMessage(); |
|
| 54 | + echo 'Error in updating : '.$e->getMessage(); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -66,18 +66,18 @@ discard block |
||
| 66 | 66 | public function resetOKAction() |
| 67 | 67 | { |
| 68 | 68 | $module=Icinga::app()->getModuleManager()->getModule($this->getModuleName()); |
| 69 | - require_once($module->getBaseDir() .'/bin/trap_class.php'); |
|
| 69 | + require_once($module->getBaseDir().'/bin/trap_class.php'); |
|
| 70 | 70 | $icingaweb2_etc=$this->Config()->get('config', 'icingaweb2_etc'); |
| 71 | 71 | $debug_level=2; |
| 72 | - $trap = new Trap($icingaweb2_etc); |
|
| 73 | - $trap->setLogging($debug_level,'display'); |
|
| 72 | + $trap=new Trap($icingaweb2_etc); |
|
| 73 | + $trap->setLogging($debug_level, 'display'); |
|
| 74 | 74 | try |
| 75 | 75 | { |
| 76 | 76 | $trap->reset_services(); |
| 77 | 77 | } |
| 78 | 78 | catch (Exception $e) |
| 79 | 79 | { |
| 80 | - echo 'ERROR : '. $e->getMessage(); |
|
| 80 | + echo 'ERROR : '.$e->getMessage(); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $this->setName('form_config_traps'); |
| 19 | 19 | $this->setSubmitLabel($this->translate('Save Changes')); |
| 20 | 20 | } |
| 21 | - public function setPaths($module_base_path,$icinga_base_path) |
|
| 21 | + public function setPaths($module_base_path, $icinga_base_path) |
|
| 22 | 22 | { |
| 23 | 23 | $this->module_base_path=$module_base_path; |
| 24 | 24 | $this->icinga_base_path=$icinga_base_path; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | ); |
| 83 | 83 | $retval=0; |
| 84 | 84 | $output=array(); |
| 85 | - $snmptranslate=exec('which snmptranslate',$output,$retval); |
|
| 85 | + $snmptranslate=exec('which snmptranslate', $output, $retval); |
|
| 86 | 86 | if ($retval != 0) |
| 87 | 87 | { |
| 88 | 88 | $snmptranslate='/usr/bin/snmptranslate'; |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
| 175 | - public function render(Zend_View_Interface $view = NULL) |
|
| 175 | + public function render(Zend_View_Interface $view=NULL) |
|
| 176 | 176 | { |
| 177 | 177 | |
| 178 | 178 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | public function indexAction() |
| 14 | 14 | { |
| 15 | - $this->getTabs()->add('get',array( |
|
| 15 | + $this->getTabs()->add('get', array( |
|
| 16 | 16 | 'active' => true, |
| 17 | 17 | 'label' => $this->translate('Error'), |
| 18 | 18 | 'url' => Url::fromRequest() |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | // Filters |
| 36 | 36 | |
| 37 | 37 | protected $filter; |
| 38 | - protected $enforcedFilters = array(); |
|
| 39 | - protected $searchColumns = array(); |
|
| 38 | + protected $enforcedFilters=array(); |
|
| 39 | + protected $searchColumns=array(); |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | // Must return titles in array ( id => display_name ) |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | // ****************** Day header |
| 45 | 45 | protected function renderDayIfNew($timestamp) |
| 46 | 46 | { |
| 47 | - $view = $this->getView(); |
|
| 47 | + $view=$this->getView(); |
|
| 48 | 48 | |
| 49 | 49 | // Check for date local format |
| 50 | 50 | if (in_array(setlocale(LC_ALL, 0), array('en_US.UTF-8', 'C'))) { |
| 51 | - $day = date('l, jS F Y', (int) $timestamp); |
|
| 51 | + $day=date('l, jS F Y', (int) $timestamp); |
|
| 52 | 52 | } else { |
| 53 | - $day = strftime('%A, %e. %B, %Y', (int) $timestamp); |
|
| 53 | + $day=strftime('%A, %e. %B, %Y', (int) $timestamp); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if ($this->lastDay === $day) { |
@@ -58,25 +58,25 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if ($this->lastDay === null) { |
| 61 | - $htm = "<thead>\n <tr>\n"; |
|
| 61 | + $htm="<thead>\n <tr>\n"; |
|
| 62 | 62 | } else { |
| 63 | - $htm = "</tbody>\n<thead>\n <tr>\n"; |
|
| 63 | + $htm="</tbody>\n<thead>\n <tr>\n"; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if ($this->columnCount === null) { |
| 67 | - $this->columnCount = count($this->getTitles()); |
|
| 67 | + $this->columnCount=count($this->getTitles()); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($day) . '</th>' . "\n"; |
|
| 70 | + $htm.='<th colspan="'.$this->columnCount.'">'.$view->escape($day).'</th>'."\n"; |
|
| 71 | 71 | if ($this->lastDay === null) { |
| 72 | - $htm .= " </tr>\n"; |
|
| 72 | + $htm.=" </tr>\n"; |
|
| 73 | 73 | } else { |
| 74 | - $htm .= " </tr>\n</thead>\n"; |
|
| 74 | + $htm.=" </tr>\n</thead>\n"; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $this->lastDay = $day; |
|
| 77 | + $this->lastDay=$day; |
|
| 78 | 78 | |
| 79 | - return $htm . "<tbody>\n"; |
|
| 79 | + return $htm."<tbody>\n"; |
|
| 80 | 80 | } |
| 81 | 81 | // ****************** Render table in html |
| 82 | 82 | public function __toString() |
@@ -89,28 +89,28 @@ discard block |
||
| 89 | 89 | // ****************** Static config set |
| 90 | 90 | public function setConfig($conf) |
| 91 | 91 | { |
| 92 | - $this->moduleConfig = $conf; |
|
| 92 | + $this->moduleConfig=$conf; |
|
| 93 | 93 | } |
| 94 | 94 | // ****************** View get/set |
| 95 | 95 | protected function getView() |
| 96 | 96 | { |
| 97 | 97 | if ($this->view === null) { |
| 98 | - $this->view = Icinga::app()->getViewRenderer()->view; |
|
| 98 | + $this->view=Icinga::app()->getViewRenderer()->view; |
|
| 99 | 99 | } |
| 100 | 100 | return $this->view; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | public function setView($view) |
| 104 | 104 | { |
| 105 | - $this->view = $view; |
|
| 105 | + $this->view=$view; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // Limits |
| 109 | 109 | |
| 110 | - public function limit($count = null, $offset = null) |
|
| 110 | + public function limit($count=null, $offset=null) |
|
| 111 | 111 | { |
| 112 | - $this->limit = $count; |
|
| 113 | - $this->offset = $offset; |
|
| 112 | + $this->limit=$count; |
|
| 113 | + $this->offset=$offset; |
|
| 114 | 114 | |
| 115 | 115 | return $this; |
| 116 | 116 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | public function getPaginator() |
| 141 | 141 | { |
| 142 | - $paginator = new Paginator(); |
|
| 142 | + $paginator=new Paginator(); |
|
| 143 | 143 | $paginator->setQuery($this); |
| 144 | 144 | |
| 145 | 145 | return $paginator; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | public function setConnection(Selectable $connection) |
| 151 | 151 | { |
| 152 | - $this->connection = $connection; |
|
| 152 | + $this->connection=$connection; |
|
| 153 | 153 | return $this; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | $db=$this->db(); |
| 169 | 169 | |
| 170 | - $query = $this->getBaseQuery(); |
|
| 170 | + $query=$this->getBaseQuery(); |
|
| 171 | 171 | |
| 172 | 172 | if ($this->hasLimit() || $this->hasOffset()) { |
| 173 | 173 | $query->limit($this->getLimit(), $this->getOffset()); |
@@ -189,20 +189,20 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | public function setFilter($filter) |
| 191 | 191 | { |
| 192 | - $this->filter = $filter; |
|
| 192 | + $this->filter=$filter; |
|
| 193 | 193 | return $this; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | public function getFilterEditor(Request $request) |
| 197 | 197 | { |
| 198 | - $filterEditor = Widget::create('filterEditor') |
|
| 198 | + $filterEditor=Widget::create('filterEditor') |
|
| 199 | 199 | ->setColumns(array_keys($this->getColumns())) |
| 200 | 200 | ->setSearchColumns(array_keys($this->getSearchColumns())) |
| 201 | 201 | ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') |
| 202 | 202 | ->ignoreParams('page') |
| 203 | 203 | ->handleRequest($request); |
| 204 | 204 | |
| 205 | - $filter = $filterEditor->getFilter(); |
|
| 205 | + $filter=$filterEditor->getFilter(); |
|
| 206 | 206 | $this->setFilter($filter); |
| 207 | 207 | |
| 208 | 208 | return $filterEditor; |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | // Filters |
| 33 | 33 | |
| 34 | 34 | protected $filter; |
| 35 | - protected $enforcedFilters = array(); |
|
| 36 | - protected $searchColumns = array(); |
|
| 35 | + protected $enforcedFilters=array(); |
|
| 36 | + protected $searchColumns=array(); |
|
| 37 | 37 | |
| 38 | 38 | protected function getTitles() { |
| 39 | 39 | return $this->moduleConfig->getHandlerListTitles(); |
@@ -53,34 +53,34 @@ discard block |
||
| 53 | 53 | public function render() |
| 54 | 54 | { |
| 55 | 55 | $data=$this->getTable(); |
| 56 | - $view = $this->getView(); |
|
| 57 | - $this->columnCount = count($this->getTitles()); |
|
| 56 | + $view=$this->getView(); |
|
| 57 | + $this->columnCount=count($this->getTitles()); |
|
| 58 | 58 | $this->lastDay=null; |
| 59 | 59 | // Table start |
| 60 | - $htm = '<table class="simple common-table table-row-selectable">'; |
|
| 60 | + $htm='<table class="simple common-table table-row-selectable">'; |
|
| 61 | 61 | |
| 62 | 62 | // Titles |
| 63 | - $htm .= "<thead>\n <tr>\n"; |
|
| 64 | - $titles = $this->getTitles(); |
|
| 63 | + $htm.="<thead>\n <tr>\n"; |
|
| 64 | + $titles=$this->getTitles(); |
|
| 65 | 65 | foreach ($titles as $title) |
| 66 | 66 | { |
| 67 | - $htm .= ' <th>' . $view->escape($view->translate($title)) . "</th>\n"; |
|
| 67 | + $htm.=' <th>'.$view->escape($view->translate($title))."</th>\n"; |
|
| 68 | 68 | } |
| 69 | - $htm .= " </tr>\n</thead>\n"; |
|
| 69 | + $htm.=" </tr>\n</thead>\n"; |
|
| 70 | 70 | |
| 71 | 71 | // Rows |
| 72 | - $htm .= "<tbody>\n"; |
|
| 72 | + $htm.="<tbody>\n"; |
|
| 73 | 73 | |
| 74 | 74 | foreach ($data as $row) |
| 75 | 75 | { |
| 76 | - $firstCol = true; |
|
| 76 | + $firstCol=true; |
|
| 77 | 77 | // Put date header |
| 78 | 78 | //$htm .= $this->renderDayIfNew($row->timestamp); |
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | // Render row |
| 82 | - $htm .= '<tr '.' >'; |
|
| 83 | - foreach ( $titles as $rowkey => $title) |
|
| 82 | + $htm.='<tr '.' >'; |
|
| 83 | + foreach ($titles as $rowkey => $title) |
|
| 84 | 84 | { |
| 85 | 85 | // Check missing value |
| 86 | 86 | if (property_exists($row, $rowkey)) |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | break; |
| 94 | 94 | case 'trap_oid': // try to traslate oids. |
| 95 | 95 | |
| 96 | - if ($this->doTranslate==true) |
|
| 96 | + if ($this->doTranslate == true) |
|
| 97 | 97 | { |
| 98 | 98 | $oidName=$this->MIB->translateOID($row->$rowkey); |
| 99 | 99 | if (isset($oidName['name'])) |
@@ -102,52 +102,52 @@ discard block |
||
| 102 | 102 | } |
| 103 | 103 | else |
| 104 | 104 | { |
| 105 | - $val = $row->$rowkey; |
|
| 105 | + $val=$row->$rowkey; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | else |
| 109 | 109 | { |
| 110 | - $val = $row->$rowkey; |
|
| 110 | + $val=$row->$rowkey; |
|
| 111 | 111 | } |
| 112 | 112 | break; |
| 113 | 113 | case 'host_name': // switch to hostgroup if name is null |
| 114 | 114 | if ($row->$rowkey == null) |
| 115 | 115 | { |
| 116 | - $val = $row->host_group_name; |
|
| 116 | + $val=$row->host_group_name; |
|
| 117 | 117 | } |
| 118 | 118 | else |
| 119 | 119 | { |
| 120 | - $val = $row->$rowkey; |
|
| 120 | + $val=$row->$rowkey; |
|
| 121 | 121 | } |
| 122 | 122 | break; |
| 123 | 123 | default: |
| 124 | - $val = $row->$rowkey; |
|
| 124 | + $val=$row->$rowkey; |
|
| 125 | 125 | } |
| 126 | - if ($rowkey == 'trap_oid' && $this->doTranslate==true) |
|
| 126 | + if ($rowkey == 'trap_oid' && $this->doTranslate == true) |
|
| 127 | 127 | { |
| 128 | 128 | |
| 129 | 129 | } |
| 130 | 130 | } else { |
| 131 | - $val = '-'; |
|
| 131 | + $val='-'; |
|
| 132 | 132 | } |
| 133 | 133 | if ($firstCol == true) { // Put link in first column for trap detail. |
| 134 | - $htm .= '<td>' |
|
| 134 | + $htm.='<td>' |
|
| 135 | 135 | . $view->qlink( |
| 136 | 136 | $view->escape($val), |
| 137 | 137 | Url::fromPath( |
| 138 | - $this->moduleConfig->urlPath() . '/handler/add', |
|
| 138 | + $this->moduleConfig->urlPath().'/handler/add', |
|
| 139 | 139 | array('ruleid' => $row->id) |
| 140 | 140 | ) |
| 141 | 141 | ) |
| 142 | 142 | . '</td>'; |
| 143 | 143 | } else { |
| 144 | - $htm .= '<td>' . $view->escape($val) . '</td>'; |
|
| 144 | + $htm.='<td>'.$view->escape($val).'</td>'; |
|
| 145 | 145 | } |
| 146 | 146 | $firstCol=false; |
| 147 | 147 | } |
| 148 | - $htm .= "<tr>\n"; |
|
| 148 | + $htm.="<tr>\n"; |
|
| 149 | 149 | } |
| 150 | - $htm .= "</tbody></table>\n"; |
|
| 150 | + $htm.="</tbody></table>\n"; |
|
| 151 | 151 | //$htm .= "Filter : " . $this->filter."<br>\n"; |
| 152 | 152 | return $htm; |
| 153 | 153 | |
@@ -155,14 +155,14 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | public function count() |
| 157 | 157 | { |
| 158 | - $db = $this->connection()->getConnection(); |
|
| 159 | - $query = clone($this->getBaseQuery()); |
|
| 158 | + $db=$this->connection()->getConnection(); |
|
| 159 | + $query=clone($this->getBaseQuery()); |
|
| 160 | 160 | $query->reset('order')->columns(array('COUNT(*)')); |
| 161 | 161 | $this->applyFiltersToQuery($query); |
| 162 | 162 | |
| 163 | 163 | $db=$this->db(); |
| 164 | 164 | |
| 165 | - $query = $db->select()->from( |
|
| 165 | + $query=$db->select()->from( |
|
| 166 | 166 | $this->moduleConfig->getTrapRuleName(), |
| 167 | 167 | array('COUNT(*)') |
| 168 | 168 | ); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | public function getPaginator() |
| 174 | 174 | { |
| 175 | - $paginator = new Paginator(); |
|
| 175 | + $paginator=new Paginator(); |
|
| 176 | 176 | $paginator->setQuery($this); |
| 177 | 177 | |
| 178 | 178 | return $paginator; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | $db=$this->db(); |
| 186 | 186 | |
| 187 | - $query = $this->getBaseQuery(); |
|
| 187 | + $query=$this->getBaseQuery(); |
|
| 188 | 188 | |
| 189 | 189 | if ($this->hasLimit() || $this->hasOffset()) { |
| 190 | 190 | $query->limit($this->getLimit(), $this->getOffset()); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | $db=$this->db(); |
| 199 | 199 | |
| 200 | - $query = $db->select()->from( |
|
| 200 | + $query=$db->select()->from( |
|
| 201 | 201 | $this->moduleConfig->getTrapRuleName(), |
| 202 | 202 | $this->moduleConfig->getHandlerListDisplayColumns() |
| 203 | 203 | )->order('host_name DESC,trap_oid DESC'); |
@@ -219,20 +219,20 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | public function setFilter($filter) |
| 221 | 221 | { |
| 222 | - $this->filter = $filter; |
|
| 222 | + $this->filter=$filter; |
|
| 223 | 223 | return $this; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | public function getFilterEditor(Request $request) |
| 227 | 227 | { |
| 228 | - $filterEditor = Widget::create('filterEditor') |
|
| 228 | + $filterEditor=Widget::create('filterEditor') |
|
| 229 | 229 | ->setColumns(array_keys($this->getColumns())) |
| 230 | 230 | ->setSearchColumns(array_keys($this->getSearchColumns())) |
| 231 | 231 | ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') |
| 232 | 232 | ->ignoreParams('page') |
| 233 | 233 | ->handleRequest($request); |
| 234 | 234 | |
| 235 | - $filter = $filterEditor->getFilter(); |
|
| 235 | + $filter=$filterEditor->getFilter(); |
|
| 236 | 236 | $this->setFilter($filter); |
| 237 | 237 | |
| 238 | 238 | return $filterEditor; |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | // Filters |
| 22 | 22 | |
| 23 | 23 | protected $filter; |
| 24 | - protected $enforcedFilters = array(); |
|
| 25 | - protected $searchColumns = array(); |
|
| 24 | + protected $enforcedFilters=array(); |
|
| 25 | + protected $searchColumns=array(); |
|
| 26 | 26 | |
| 27 | 27 | protected function getTitles() { |
| 28 | 28 | // TODO : check moduleconfig is set |
@@ -38,60 +38,60 @@ discard block |
||
| 38 | 38 | public function render() |
| 39 | 39 | { |
| 40 | 40 | $data=$this->getTable(); |
| 41 | - $view = $this->getView(); |
|
| 42 | - $this->columnCount = count($this->getTitles()); |
|
| 41 | + $view=$this->getView(); |
|
| 42 | + $this->columnCount=count($this->getTitles()); |
|
| 43 | 43 | $this->lastDay=null; |
| 44 | 44 | // Table start |
| 45 | - $htm = '<table class="simple common-table table-row-selectable">'; |
|
| 45 | + $htm='<table class="simple common-table table-row-selectable">'; |
|
| 46 | 46 | |
| 47 | 47 | // Titles |
| 48 | - $htm .= "<thead>\n <tr>\n"; |
|
| 49 | - $titles = $this->getTitles(); |
|
| 48 | + $htm.="<thead>\n <tr>\n"; |
|
| 49 | + $titles=$this->getTitles(); |
|
| 50 | 50 | foreach ($titles as $title) |
| 51 | 51 | { |
| 52 | - $htm .= ' <th>' . $view->escape($view->translate($title)) . "</th>\n"; |
|
| 52 | + $htm.=' <th>'.$view->escape($view->translate($title))."</th>\n"; |
|
| 53 | 53 | } |
| 54 | - $htm .= " </tr>\n</thead>\n"; |
|
| 54 | + $htm.=" </tr>\n</thead>\n"; |
|
| 55 | 55 | |
| 56 | 56 | // Rows |
| 57 | - $htm .= "<tbody>\n"; |
|
| 57 | + $htm.="<tbody>\n"; |
|
| 58 | 58 | |
| 59 | 59 | foreach ($data as $row) |
| 60 | 60 | { |
| 61 | - $firstCol = true; |
|
| 61 | + $firstCol=true; |
|
| 62 | 62 | // Put date header |
| 63 | - $htm .= $this->renderDayIfNew($row->timestamp); |
|
| 63 | + $htm.=$this->renderDayIfNew($row->timestamp); |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | // Render row |
| 67 | - $htm .= '<tr '.' >'; |
|
| 68 | - foreach ( $titles as $rowkey => $title) |
|
| 67 | + $htm.='<tr '.' >'; |
|
| 68 | + foreach ($titles as $rowkey => $title) |
|
| 69 | 69 | { |
| 70 | 70 | // Check missing value |
| 71 | 71 | if (property_exists($row, $rowkey)) |
| 72 | 72 | { |
| 73 | - $val = ($rowkey=='timestamp') ? strftime('%T',$row->$rowkey) : $row->$rowkey; |
|
| 73 | + $val=($rowkey == 'timestamp') ? strftime('%T', $row->$rowkey) : $row->$rowkey; |
|
| 74 | 74 | } else { |
| 75 | - $val = '-'; |
|
| 75 | + $val='-'; |
|
| 76 | 76 | } |
| 77 | 77 | if ($firstCol == true) { // Put link in first column for trap detail. |
| 78 | - $htm .= '<td>' |
|
| 78 | + $htm.='<td>' |
|
| 79 | 79 | . $view->qlink( |
| 80 | 80 | $view->escape($val), |
| 81 | 81 | Url::fromPath( |
| 82 | - $this->moduleConfig->urlPath() . '/received/trapdetail', |
|
| 82 | + $this->moduleConfig->urlPath().'/received/trapdetail', |
|
| 83 | 83 | array('id' => $row->id) |
| 84 | 84 | ) |
| 85 | 85 | ) |
| 86 | 86 | . '</td>'; |
| 87 | 87 | } else { |
| 88 | - $htm .= '<td>' . $view->escape($val) . '</td>'; |
|
| 88 | + $htm.='<td>'.$view->escape($val).'</td>'; |
|
| 89 | 89 | } |
| 90 | 90 | $firstCol=false; |
| 91 | 91 | } |
| 92 | - $htm .= "<tr>\n"; |
|
| 92 | + $htm.="<tr>\n"; |
|
| 93 | 93 | } |
| 94 | - $htm .= "</tbody></table>\n"; |
|
| 94 | + $htm.="</tbody></table>\n"; |
|
| 95 | 95 | //$htm .= "Filter : " . $this->filter."<br>\n"; |
| 96 | 96 | return $htm; |
| 97 | 97 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | { |
| 102 | 102 | $db=$this->db(); |
| 103 | 103 | |
| 104 | - $query = $db->select()->from( |
|
| 104 | + $query=$db->select()->from( |
|
| 105 | 105 | $this->moduleConfig->getTrapTableName(), |
| 106 | 106 | array('COUNT(*)') |
| 107 | 107 | ); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | public function getPaginator() |
| 114 | 114 | { |
| 115 | - $paginator = new Paginator(); |
|
| 115 | + $paginator=new Paginator(); |
|
| 116 | 116 | $paginator->setQuery($this); |
| 117 | 117 | |
| 118 | 118 | return $paginator; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | { |
| 125 | 125 | $db=$this->db(); |
| 126 | 126 | |
| 127 | - $query = $this->getBaseQuery(); |
|
| 127 | + $query=$this->getBaseQuery(); |
|
| 128 | 128 | $this->applyFiltersToQuery($query); |
| 129 | 129 | if ($this->hasLimit() || $this->hasOffset()) { |
| 130 | 130 | $query->limit($this->getLimit(), $this->getOffset()); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | $db=$this->db(); |
| 139 | 139 | |
| 140 | - $query = $db->select()->from( |
|
| 140 | + $query=$db->select()->from( |
|
| 141 | 141 | $this->moduleConfig->getTrapTableName(), |
| 142 | 142 | $this->moduleConfig->getTrapListDisplayColumns() |
| 143 | 143 | )->order('timestamp DESC'); |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | protected $filter_Handler; |
| 151 | 151 | protected $filter_query=''; |
| 152 | 152 | protected $filter_done=''; |
| 153 | - protected $filter_query_list=array('q','done'); |
|
| 153 | + protected $filter_query_list=array('q', 'done'); |
|
| 154 | 154 | public function renderFilterHTML() |
| 155 | 155 | { |
| 156 | 156 | $htm=' <form id="filter" name="mainFilter" |
@@ -160,17 +160,17 @@ discard block |
||
| 160 | 160 | $htm.='<input type="text" name="q" title="Search is simple! Try to combine multiple words" |
| 161 | 161 | placeholder="Search..." class="search" value="'.$this->filter_query.'">'; |
| 162 | 162 | $htm.='<input type="checkbox" id="checkbox_done" name="done" value="1" class="autosubmit" '; |
| 163 | - if ($this->filter_done == 1) { $htm.=' checked ';} |
|
| 163 | + if ($this->filter_done == 1) { $htm.=' checked '; } |
|
| 164 | 164 | $htm.='> <label for="checkbox_done">Hide processed traps</label>'; |
| 165 | 165 | $htm.='</form>'; |
| 166 | 166 | return $htm; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function updateFilter($handler,$filter) |
|
| 169 | + public function updateFilter($handler, $filter) |
|
| 170 | 170 | { |
| 171 | 171 | $this->filter_Handler=$handler->remove($this->filter_query_list)->__toString(); |
| 172 | - $this->filter_query=(isset($filter['q']))?$this->filter_query=$filter['q']:''; |
|
| 173 | - $this->filter_done=(isset($filter['done']))?$this->filter_done=$filter['done']:0; |
|
| 172 | + $this->filter_query=(isset($filter['q'])) ? $this->filter_query=$filter['q'] : ''; |
|
| 173 | + $this->filter_done=(isset($filter['done'])) ? $this->filter_done=$filter['done'] : 0; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | protected function getSearchColumns() |
@@ -185,20 +185,20 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | public function setFilter($filter) |
| 187 | 187 | { |
| 188 | - $this->filter = $filter; |
|
| 188 | + $this->filter=$filter; |
|
| 189 | 189 | return $this; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | public function getFilterEditor(Request $request) |
| 193 | 193 | { |
| 194 | - $filterEditor = Widget::create('filterEditor') |
|
| 194 | + $filterEditor=Widget::create('filterEditor') |
|
| 195 | 195 | ->setColumns(array_keys($this->getColumns())) |
| 196 | 196 | ->setSearchColumns(array_keys($this->getSearchColumns())) |
| 197 | 197 | ->preserveParams('limit', 'sort', 'dir', 'view', 'backend') |
| 198 | 198 | ->ignoreParams('page') |
| 199 | 199 | ->handleRequest($request); |
| 200 | 200 | |
| 201 | - $filter = $filterEditor->getFilter(); |
|
| 201 | + $filter=$filterEditor->getFilter(); |
|
| 202 | 202 | $this->setFilter($filter); |
| 203 | 203 | |
| 204 | 204 | return $filterEditor; |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | { |
| 213 | 213 | $sql.='('; |
| 214 | 214 | $first=1; |
| 215 | - foreach($this->moduleConfig->getTrapListSearchColumns() as $column) |
|
| 215 | + foreach ($this->moduleConfig->getTrapListSearchColumns() as $column) |
|
| 216 | 216 | { |
| 217 | - if ($first==0) $sql.=' OR '; |
|
| 217 | + if ($first == 0) $sql.=' OR '; |
|
| 218 | 218 | $first=0; |
| 219 | 219 | $sql.=" CAST(".$column." AS char(100)) LIKE '%".$this->filter_query."%' "; |
| 220 | 220 | } |
@@ -8,19 +8,19 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class Icinga2API |
| 10 | 10 | { |
| 11 | - protected $version = 'v1'; //< icinga2 api version |
|
| 11 | + protected $version='v1'; //< icinga2 api version |
|
| 12 | 12 | |
| 13 | - protected $host; //< icinga2 host name or IP |
|
| 14 | - protected $port; //< icinga2 api port |
|
| 13 | + protected $host; //< icinga2 host name or IP |
|
| 14 | + protected $port; //< icinga2 api port |
|
| 15 | 15 | |
| 16 | - protected $user; //< user name |
|
| 17 | - protected $pass; //< user password |
|
| 18 | - protected $usercert; //< user key for certificate auth (NOT IMPLEMENTED) |
|
| 19 | - protected $authmethod='pass'; //< Authentication : 'pass' or 'cert' |
|
| 16 | + protected $user; //< user name |
|
| 17 | + protected $pass; //< user password |
|
| 18 | + protected $usercert; //< user key for certificate auth (NOT IMPLEMENTED) |
|
| 19 | + protected $authmethod='pass'; //< Authentication : 'pass' or 'cert' |
|
| 20 | 20 | |
| 21 | 21 | protected $curl; |
| 22 | 22 | // http://php.net/manual/de/function.json-last-error.php#119985 |
| 23 | - protected $errorReference = [ |
|
| 23 | + protected $errorReference=[ |
|
| 24 | 24 | JSON_ERROR_NONE => 'No error has occurred.', |
| 25 | 25 | JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded.', |
| 26 | 26 | JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON.', |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | JSON_ERROR_INF_OR_NAN => 'One or more NAN or INF values in the value to be encoded.', |
| 32 | 32 | JSON_ERROR_UNSUPPORTED_TYPE => 'A value of a type that cannot be encoded was given.', |
| 33 | 33 | ]; |
| 34 | - const JSON_UNKNOWN_ERROR = 'Unknown error.'; |
|
| 34 | + const JSON_UNKNOWN_ERROR='Unknown error.'; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Creates Icinga2API object |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param string $host host name or IP |
| 40 | 40 | * @param number $port API port |
| 41 | 41 | */ |
| 42 | - public function __construct($host, $port = 5665) |
|
| 42 | + public function __construct($host, $port=5665) |
|
| 43 | 43 | { |
| 44 | 44 | $this->host=$host; |
| 45 | 45 | $this->port=$port; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param string $user |
| 50 | 50 | * @param string $pass |
| 51 | 51 | */ |
| 52 | - public function setCredentials($user,$pass) |
|
| 52 | + public function setCredentials($user, $pass) |
|
| 53 | 53 | { |
| 54 | 54 | $this->user=$user; |
| 55 | 55 | $this->pass=$pass; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @param string $user |
| 62 | 62 | * @param string $usercert |
| 63 | 63 | */ |
| 64 | - public function setCredentialskey($user,$usercert) |
|
| 64 | + public function setCredentialskey($user, $usercert) |
|
| 65 | 65 | { |
| 66 | 66 | $this->user=$user; |
| 67 | 67 | $this->usercert=$usercert; |
@@ -84,13 +84,13 @@ discard block |
||
| 84 | 84 | if (property_exists($result, 'results') && property_exists($result->results[0], 'permissions')) |
| 85 | 85 | { |
| 86 | 86 | |
| 87 | - foreach ( $permissions as $mustPermission) |
|
| 87 | + foreach ($permissions as $mustPermission) |
|
| 88 | 88 | { |
| 89 | 89 | $curPermOK=0; |
| 90 | - foreach ( $result->results[0]->permissions as $curPermission) |
|
| 90 | + foreach ($result->results[0]->permissions as $curPermission) |
|
| 91 | 91 | { |
| 92 | - $curPermission=preg_replace('/\*/','.*',$curPermission); // put * as .* to created a regexp |
|
| 93 | - if (preg_match('#'.$curPermission.'#',$mustPermission)) |
|
| 92 | + $curPermission=preg_replace('/\*/', '.*', $curPermission); // put * as .* to created a regexp |
|
| 93 | + if (preg_match('#'.$curPermission.'#', $mustPermission)) |
|
| 94 | 94 | { |
| 95 | 95 | $curPermOK=1; |
| 96 | 96 | break; |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | if ($permOk == 0) |
| 107 | 107 | { |
| 108 | - return array(true,'API connection OK, but missing permission : '.$permMissing); |
|
| 108 | + return array(true, 'API connection OK, but missing permission : '.$permMissing); |
|
| 109 | 109 | } |
| 110 | - return array(false,'API connection OK'); |
|
| 110 | + return array(false, 'API connection OK'); |
|
| 111 | 111 | |
| 112 | 112 | } |
| 113 | - return array(true,'API connection OK, but cannot get permissions'); |
|
| 113 | + return array(true, 'API connection OK, but cannot get permissions'); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | protected function curl() { |
| 127 | 127 | if ($this->curl === null) { |
| 128 | - $this->curl = curl_init(sprintf('https://%s:%d', $this->host, $this->port)); |
|
| 128 | + $this->curl=curl_init(sprintf('https://%s:%d', $this->host, $this->port)); |
|
| 129 | 129 | if (!$this->curl) { |
| 130 | - throw new Exception('CURL INIT ERROR: ' . curl_error($this->curl)); |
|
| 130 | + throw new Exception('CURL INIT ERROR: '.curl_error($this->curl)); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | return $this->curl; |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @param string $display : service passive check output |
| 142 | 142 | * @return array (status = true (oK) or false (nok), string message) |
| 143 | 143 | */ |
| 144 | - public function serviceCheckResult($host,$service,$state,$display) |
|
| 144 | + public function serviceCheckResult($host, $service, $state, $display) |
|
| 145 | 145 | { |
| 146 | 146 | //Send a POST request to the URL endpoint /v1/actions/process-check-result |
| 147 | 147 | //actions/process-check-result?service=example.localdomain!passive-ping6 |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | return array(false, $e->getMessage()); |
| 161 | 161 | } |
| 162 | - if (property_exists($result,'error') ) |
|
| 162 | + if (property_exists($result, 'error')) |
|
| 163 | 163 | { |
| 164 | - if (property_exists($result,'status')) |
|
| 164 | + if (property_exists($result, 'status')) |
|
| 165 | 165 | { |
| 166 | 166 | $message=$result->status; |
| 167 | 167 | } |
@@ -169,21 +169,21 @@ discard block |
||
| 169 | 169 | { |
| 170 | 170 | $message="Unkown status"; |
| 171 | 171 | } |
| 172 | - return array(false , 'Ret code ' .$result->error.' : '.$message); |
|
| 172 | + return array(false, 'Ret code '.$result->error.' : '.$message); |
|
| 173 | 173 | } |
| 174 | 174 | if (property_exists($result, 'results')) |
| 175 | 175 | { |
| 176 | 176 | if (isset($result->results[0])) |
| 177 | 177 | { |
| 178 | - return array(true,'code '.$result->results[0]->code.' : '.$result->results[0]->status); |
|
| 178 | + return array(true, 'code '.$result->results[0]->code.' : '.$result->results[0]->status); |
|
| 179 | 179 | } |
| 180 | 180 | else |
| 181 | 181 | { |
| 182 | - return array(false,'Service not found'); |
|
| 182 | + return array(false, 'Service not found'); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | } |
| 186 | - return array(false,'Unkown result, open issue with this : '.print_r($result,true)); |
|
| 186 | + return array(false, 'Unkown result, open issue with this : '.print_r($result, true)); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $url='objects/hosts'; |
| 205 | 205 | $body=array( |
| 206 | 206 | "filter" => 'host.address=="'.$ip.'" || host.address6=="'.$ip.'"', |
| 207 | - "attrs" => array('__name','name','display_name') |
|
| 207 | + "attrs" => array('__name', 'name', 'display_name') |
|
| 208 | 208 | ); |
| 209 | 209 | try |
| 210 | 210 | { |
@@ -214,24 +214,24 @@ discard block |
||
| 214 | 214 | throw new Exception($e->getMessage()); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if (property_exists($result,'error') ) |
|
| 217 | + if (property_exists($result, 'error')) |
|
| 218 | 218 | { |
| 219 | - if (property_exists($result,'status')) |
|
| 219 | + if (property_exists($result, 'status')) |
|
| 220 | 220 | { |
| 221 | - throw new Exception('Ret code ' .$result->error.' : ' . $result->status); |
|
| 221 | + throw new Exception('Ret code '.$result->error.' : '.$result->status); |
|
| 222 | 222 | } |
| 223 | 223 | else |
| 224 | 224 | { |
| 225 | - throw new Exception('Ret code ' .$result->error.' : Unkown status'); |
|
| 225 | + throw new Exception('Ret code '.$result->error.' : Unkown status'); |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | 228 | if (property_exists($result, 'results')) |
| 229 | 229 | { |
| 230 | 230 | $numHost=0; |
| 231 | 231 | $hostArray=array(); |
| 232 | - while (isset($result->results[$numHost]) && property_exists ($result->results[$numHost],'attrs')) |
|
| 232 | + while (isset($result->results[$numHost]) && property_exists($result->results[$numHost], 'attrs')) |
|
| 233 | 233 | { |
| 234 | - $hostArray[$numHost] = $result->results[$numHost]->attrs; |
|
| 234 | + $hostArray[$numHost]=$result->results[$numHost]->attrs; |
|
| 235 | 235 | $numHost++; |
| 236 | 236 | } |
| 237 | 237 | return $hostArray; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $url='objects/hosts'; |
| 251 | 251 | $body=array( |
| 252 | 252 | "filter" => '\"'.$hostGroup.'\" in host.groups', |
| 253 | - "attrs" => array('address','address','name') |
|
| 253 | + "attrs" => array('address', 'address', 'name') |
|
| 254 | 254 | ); |
| 255 | 255 | try |
| 256 | 256 | { |
@@ -260,25 +260,25 @@ discard block |
||
| 260 | 260 | throw new Exception($e->getMessage()); |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if (property_exists($result,'error') ) |
|
| 263 | + if (property_exists($result, 'error')) |
|
| 264 | 264 | { |
| 265 | - if (property_exists($result,'status')) |
|
| 265 | + if (property_exists($result, 'status')) |
|
| 266 | 266 | { |
| 267 | - throw new Exception('Ret code ' .$result->error.' : ' . $result->status); |
|
| 267 | + throw new Exception('Ret code '.$result->error.' : '.$result->status); |
|
| 268 | 268 | } |
| 269 | 269 | else |
| 270 | 270 | { |
| 271 | - throw new Exception('Ret code ' .$result->error.' : Unkown status'); |
|
| 271 | + throw new Exception('Ret code '.$result->error.' : Unkown status'); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | if (property_exists($result, 'results')) |
| 275 | 275 | { |
| 276 | 276 | $numHost=0; |
| 277 | 277 | $hostArray=array(); |
| 278 | - while (isset($result->results[$numHost]) && property_exists ($result->results[$numHost],'attrs')) |
|
| 278 | + while (isset($result->results[$numHost]) && property_exists($result->results[$numHost], 'attrs')) |
|
| 279 | 279 | { |
| 280 | - $hostArray[$numHost] = $result->results[$numHost]->attrs; |
|
| 281 | - $hostArray[$numHost]->name = $result->results[$numHost]->name; |
|
| 280 | + $hostArray[$numHost]=$result->results[$numHost]->attrs; |
|
| 281 | + $hostArray[$numHost]->name=$result->results[$numHost]->name; |
|
| 282 | 282 | $numHost++; |
| 283 | 283 | } |
| 284 | 284 | return $hostArray; |
@@ -296,23 +296,23 @@ discard block |
||
| 296 | 296 | * @return array |
| 297 | 297 | */ |
| 298 | 298 | public function request($method, $url, $headers, $body) { |
| 299 | - $auth = sprintf('%s:%s', $this->user, $this->pass); |
|
| 300 | - $curlHeaders = array("Accept: application/json"); |
|
| 299 | + $auth=sprintf('%s:%s', $this->user, $this->pass); |
|
| 300 | + $curlHeaders=array("Accept: application/json"); |
|
| 301 | 301 | if ($body !== null) { |
| 302 | - $body = json_encode($body); |
|
| 302 | + $body=json_encode($body); |
|
| 303 | 303 | array_push($curlHeaders, 'Content-Type: application/json'); |
| 304 | 304 | //array_push($curlHeaders, 'X-HTTP-Method-Override: GET'); |
| 305 | 305 | } |
| 306 | 306 | //var_dump($body); |
| 307 | 307 | //var_dump($this->url($url)); |
| 308 | 308 | if ($headers !== null) { |
| 309 | - $curlFinalHeaders = array_merge($curlHeaders, $headers); |
|
| 309 | + $curlFinalHeaders=array_merge($curlHeaders, $headers); |
|
| 310 | 310 | } else |
| 311 | 311 | { |
| 312 | 312 | $curlFinalHeaders=$curlHeaders; |
| 313 | 313 | } |
| 314 | - $curl = $this->curl(); |
|
| 315 | - $opts = array( |
|
| 314 | + $curl=$this->curl(); |
|
| 315 | + $opts=array( |
|
| 316 | 316 | CURLOPT_URL => $this->url($url), |
| 317 | 317 | CURLOPT_HTTPHEADER => $curlFinalHeaders, |
| 318 | 318 | CURLOPT_USERPWD => $auth, |
@@ -323,14 +323,14 @@ discard block |
||
| 323 | 323 | CURLOPT_SSL_VERIFYPEER => false, |
| 324 | 324 | ); |
| 325 | 325 | if ($body !== null) { |
| 326 | - $opts[CURLOPT_POSTFIELDS] = $body; |
|
| 326 | + $opts[CURLOPT_POSTFIELDS]=$body; |
|
| 327 | 327 | } |
| 328 | 328 | curl_setopt_array($curl, $opts); |
| 329 | - $res = curl_exec($curl); |
|
| 329 | + $res=curl_exec($curl); |
|
| 330 | 330 | if ($res === false) { |
| 331 | - throw new Exception('CURL ERROR: ' . curl_error($curl)); |
|
| 331 | + throw new Exception('CURL ERROR: '.curl_error($curl)); |
|
| 332 | 332 | } |
| 333 | - $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); |
|
| 333 | + $statusCode=curl_getinfo($curl, CURLINFO_HTTP_CODE); |
|
| 334 | 334 | if ($statusCode === 401) { |
| 335 | 335 | throw new Exception('Unable to authenticate, please check your API credentials'); |
| 336 | 336 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * @return array json decoded |
| 345 | 345 | */ |
| 346 | 346 | protected function fromJsonResult($json) { |
| 347 | - $result = @json_decode($json); |
|
| 347 | + $result=@json_decode($json); |
|
| 348 | 348 | //var_dump($json); |
| 349 | 349 | if ($result === null) { |
| 350 | 350 | throw new Exception('Parsing JSON failed: '.$this->getLastJsonErrorMessage(json_last_error())); |