@@ -40,8 +40,7 @@ |
||
| 40 | 40 | $query = $dataBase->select()->from($Config->getTrapRuleName(),array('COUNT(*)')); |
| 41 | 41 | printf("Number of rules : %s\n", $dataBase->fetchOne($query) ); |
| 42 | 42 | |
| 43 | - } |
|
| 44 | - catch (Exception $e) |
|
| 43 | + } catch (Exception $e) |
|
| 45 | 44 | { |
| 46 | 45 | printf('Error in DB : %s\n', $e->getMessage()); |
| 47 | 46 | } |
@@ -42,14 +42,12 @@ discard block |
||
| 42 | 42 | if ($days=='<default>') |
| 43 | 43 | { |
| 44 | 44 | $trap->eraseOldTraps(); |
| 45 | - } |
|
| 46 | - else |
|
| 45 | + } else |
|
| 47 | 46 | { |
| 48 | 47 | $trap->eraseOldTraps($days); |
| 49 | 48 | } |
| 50 | 49 | |
| 51 | - } |
|
| 52 | - catch (Exception $e) |
|
| 50 | + } catch (Exception $e) |
|
| 53 | 51 | { |
| 54 | 52 | echo 'Error in updating : ' . $e->getMessage(); |
| 55 | 53 | } |
@@ -74,8 +72,7 @@ discard block |
||
| 74 | 72 | try |
| 75 | 73 | { |
| 76 | 74 | $trap->reset_services(); |
| 77 | - } |
|
| 78 | - catch (Exception $e) |
|
| 75 | + } catch (Exception $e) |
|
| 79 | 76 | { |
| 80 | 77 | echo 'ERROR : '. $e->getMessage(); |
| 81 | 78 | } |
@@ -62,8 +62,7 @@ discard block |
||
| 62 | 62 | if ($pid == 1) |
| 63 | 63 | { |
| 64 | 64 | $trap->setLogging($logLevel,'display'); |
| 65 | - } |
|
| 66 | - else |
|
| 65 | + } else |
|
| 67 | 66 | { // use default display TODO : if default is 'display' son process will be killed at first output.... |
| 68 | 67 | if ($pid != 0) |
| 69 | 68 | { |
@@ -72,8 +71,7 @@ discard block |
||
| 72 | 71 | fclose($file); |
| 73 | 72 | echo "OK : process $pid in bckground"; |
| 74 | 73 | return 0; |
| 75 | - } |
|
| 76 | - else |
|
| 74 | + } else |
|
| 77 | 75 | { // son process : close all file descriptors and go to a new session |
| 78 | 76 | fclose($file); |
| 79 | 77 | // $sid = posix_setsid(); |
@@ -83,8 +81,7 @@ discard block |
||
| 83 | 81 | try |
| 84 | 82 | { |
| 85 | 83 | $trap->update_mib_database(false,$forceCheck); |
| 86 | - } |
|
| 87 | - catch (Exception $e) |
|
| 84 | + } catch (Exception $e) |
|
| 88 | 85 | { |
| 89 | 86 | $trap->trapLog('Error in updating : ' . $e->getMessage(),2); |
| 90 | 87 | } |
@@ -101,8 +98,7 @@ discard block |
||
| 101 | 98 | $trap->update_mib_database(true,$forceCheck); |
| 102 | 99 | echo "Done\n"; |
| 103 | 100 | |
| 104 | - } |
|
| 105 | - catch (Exception $e) |
|
| 101 | + } catch (Exception $e) |
|
| 106 | 102 | { |
| 107 | 103 | echo 'Error in updating : ' . $e->getMessage(); |
| 108 | 104 | } |
@@ -144,8 +140,7 @@ discard block |
||
| 144 | 140 | $query = $db->select()->from($Config->getTrapRuleName(),array('COUNT(*)')); |
| 145 | 141 | echo "Number of rules : " . $db->fetchOne($query) ."\n"; |
| 146 | 142 | |
| 147 | - } |
|
| 148 | - catch (Exception $e) |
|
| 143 | + } catch (Exception $e) |
|
| 149 | 144 | { |
| 150 | 145 | echo 'Error in DB : ' . $e->getMessage(); |
| 151 | 146 | } |
@@ -76,9 +76,10 @@ discard block |
||
| 76 | 76 | ->from($this->moduleConfig->getTrapTableName(),$elmts) |
| 77 | 77 | ->where('id=?',$trapid); |
| 78 | 78 | $trapDetail=$db->fetchRow($query); |
| 79 | - if ( $trapDetail == null) throw new Exception('No traps was found with id = '.$trapid); |
|
| 80 | - } |
|
| 81 | - catch (Exception $e) |
|
| 79 | + if ( $trapDetail == null) { |
|
| 80 | + throw new Exception('No traps was found with id = '.$trapid); |
|
| 81 | + } |
|
| 82 | + } catch (Exception $e) |
|
| 82 | 83 | { |
| 83 | 84 | $this->displayExitError('Trap detail',$e->getMessage()); |
| 84 | 85 | } |
@@ -108,8 +109,7 @@ discard block |
||
| 108 | 109 | ->from($this->moduleConfig->getTrapDataTableName(),$data_elmts) |
| 109 | 110 | ->where('trap_id=?',$trapid); |
| 110 | 111 | $trapDetail=$db->fetchAll($query); |
| 111 | - } |
|
| 112 | - catch (Exception $e) |
|
| 112 | + } catch (Exception $e) |
|
| 113 | 113 | { |
| 114 | 114 | $this->displayExitError('Trap detail',$e->getMessage()); |
| 115 | 115 | } |
@@ -117,8 +117,7 @@ discard block |
||
| 117 | 117 | if ($trapDetail == null ) |
| 118 | 118 | { |
| 119 | 119 | $this->view->data=false; |
| 120 | - } |
|
| 121 | - else |
|
| 120 | + } else |
|
| 122 | 121 | { |
| 123 | 122 | $this->view->data=true; |
| 124 | 123 | // Store result in array. |
@@ -204,8 +203,7 @@ discard block |
||
| 204 | 203 | $ip=$postData['IP']; |
| 205 | 204 | $oid=$postData['OID']; |
| 206 | 205 | $action=$postData['action']; |
| 207 | - } |
|
| 208 | - else |
|
| 206 | + } else |
|
| 209 | 207 | { |
| 210 | 208 | $this->_helper->json(array('status'=>'Missing variables')); |
| 211 | 209 | } |
@@ -256,7 +256,9 @@ discard block |
||
| 256 | 256 | $first=1; |
| 257 | 257 | foreach($this->moduleConfig->getTrapListSearchColumns() as $column) |
| 258 | 258 | { |
| 259 | - if ($first==0) $sql.=' OR '; |
|
| 259 | + if ($first==0) { |
|
| 260 | + $sql.=' OR '; |
|
| 261 | + } |
|
| 260 | 262 | $first=0; |
| 261 | 263 | $sql.=" ".$column." LIKE '%".$this->filter_query."%' "; |
| 262 | 264 | } |
@@ -264,10 +266,14 @@ discard block |
||
| 264 | 266 | } |
| 265 | 267 | if ($this->filter_done == 1) |
| 266 | 268 | { |
| 267 | - if ($sql != '') $sql.=' AND '; |
|
| 269 | + if ($sql != '') { |
|
| 270 | + $sql.=' AND '; |
|
| 271 | + } |
|
| 268 | 272 | $sql.="(status != 'done')"; |
| 269 | 273 | } |
| 270 | - if ($sql != '') $query->where($sql); |
|
| 274 | + if ($sql != '') { |
|
| 275 | + $query->where($sql); |
|
| 276 | + } |
|
| 271 | 277 | return $query; |
| 272 | 278 | } |
| 273 | 279 | |
@@ -99,13 +99,11 @@ discard block |
||
| 99 | 99 | if (isset($oidName['name'])) |
| 100 | 100 | { |
| 101 | 101 | $val=$oidName['name']; |
| 102 | - } |
|
| 103 | - else |
|
| 102 | + } else |
|
| 104 | 103 | { |
| 105 | 104 | $val = $row->$rowkey; |
| 106 | 105 | } |
| 107 | - } |
|
| 108 | - else |
|
| 106 | + } else |
|
| 109 | 107 | { |
| 110 | 108 | $val = $row->$rowkey; |
| 111 | 109 | } |
@@ -114,8 +112,7 @@ discard block |
||
| 114 | 112 | if ($row->$rowkey == null) |
| 115 | 113 | { |
| 116 | 114 | $val = $row->host_group_name; |
| 117 | - } |
|
| 118 | - else |
|
| 115 | + } else |
|
| 119 | 116 | { |
| 120 | 117 | $val = $row->$rowkey; |
| 121 | 118 | } |
@@ -214,7 +214,9 @@ discard block |
||
| 214 | 214 | $first=1; |
| 215 | 215 | foreach($this->moduleConfig->getTrapListSearchColumns() as $column) |
| 216 | 216 | { |
| 217 | - if ($first==0) $sql.=' OR '; |
|
| 217 | + if ($first==0) { |
|
| 218 | + $sql.=' OR '; |
|
| 219 | + } |
|
| 218 | 220 | $first=0; |
| 219 | 221 | $sql.=" CAST(".$column." AS char(100)) LIKE '%".$this->filter_query."%' "; |
| 220 | 222 | } |
@@ -222,10 +224,14 @@ discard block |
||
| 222 | 224 | } |
| 223 | 225 | if ($this->filter_done == 1) |
| 224 | 226 | { |
| 225 | - if ($sql != '') $sql.=' AND '; |
|
| 227 | + if ($sql != '') { |
|
| 228 | + $sql.=' AND '; |
|
| 229 | + } |
|
| 226 | 230 | $sql.="(status != 'done')"; |
| 227 | 231 | } |
| 228 | - if ($sql != '') $query->where($sql); |
|
| 232 | + if ($sql != '') { |
|
| 233 | + $query->where($sql); |
|
| 234 | + } |
|
| 229 | 235 | return $query; |
| 230 | 236 | } |
| 231 | 237 | |
@@ -164,8 +164,7 @@ discard block |
||
| 164 | 164 | if (property_exists($result,'status')) |
| 165 | 165 | { |
| 166 | 166 | $message=$result->status; |
| 167 | - } |
|
| 168 | - else |
|
| 167 | + } else |
|
| 169 | 168 | { |
| 170 | 169 | $message="Unkown status"; |
| 171 | 170 | } |
@@ -176,8 +175,7 @@ discard block |
||
| 176 | 175 | if (isset($result->results[0])) |
| 177 | 176 | { |
| 178 | 177 | return array(true,'code '.$result->results[0]->code.' : '.$result->results[0]->status); |
| 179 | - } |
|
| 180 | - else |
|
| 178 | + } else |
|
| 181 | 179 | { |
| 182 | 180 | return array(false,'Service not found'); |
| 183 | 181 | } |
@@ -219,8 +217,7 @@ discard block |
||
| 219 | 217 | if (property_exists($result,'status')) |
| 220 | 218 | { |
| 221 | 219 | throw new Exception('Ret code ' .$result->error.' : ' . $result->status); |
| 222 | - } |
|
| 223 | - else |
|
| 220 | + } else |
|
| 224 | 221 | { |
| 225 | 222 | throw new Exception('Ret code ' .$result->error.' : Unkown status'); |
| 226 | 223 | } |
@@ -265,8 +262,7 @@ discard block |
||
| 265 | 262 | if (property_exists($result,'status')) |
| 266 | 263 | { |
| 267 | 264 | throw new Exception('Ret code ' .$result->error.' : ' . $result->status); |
| 268 | - } |
|
| 269 | - else |
|
| 265 | + } else |
|
| 270 | 266 | { |
| 271 | 267 | throw new Exception('Ret code ' .$result->error.' : Unkown status'); |
| 272 | 268 | } |
@@ -90,7 +90,9 @@ discard block |
||
| 90 | 90 | array('id' => 'id')) |
| 91 | 91 | ->where("oid = '".$trap."'") ; |
| 92 | 92 | $id=$dbconn->fetchRow($query); |
| 93 | - if ( ($id == null) || ! property_exists($id,'id') ) return null; |
|
| 93 | + if ( ($id == null) || ! property_exists($id,'id') ) { |
|
| 94 | + return null; |
|
| 95 | + } |
|
| 94 | 96 | |
| 95 | 97 | $query=$dbconn->select() |
| 96 | 98 | ->from( |
@@ -103,7 +105,9 @@ discard block |
||
| 103 | 105 | 'o.trap_id='.$id->id ) |
| 104 | 106 | ->where("o.object_id = c.id"); |
| 105 | 107 | $listObjects=$dbconn->fetchAll($query); |
| 106 | - if ( count($listObjects)==0 ) return null; |
|
| 108 | + if ( count($listObjects)==0 ) { |
|
| 109 | + return null; |
|
| 110 | + } |
|
| 107 | 111 | |
| 108 | 112 | foreach ($listObjects as $val) |
| 109 | 113 | { |
@@ -124,7 +128,10 @@ discard block |
||
| 124 | 128 | */ |
| 125 | 129 | public function translateOID($oid) |
| 126 | 130 | { |
| 127 | - if (!preg_match('/^\./',$oid)) $oid = '.' . $oid; // Add a leading '.' |
|
| 131 | + if (!preg_match('/^\./',$oid)) { |
|
| 132 | + $oid = '.' . $oid; |
|
| 133 | + } |
|
| 134 | + // Add a leading '.' |
|
| 128 | 135 | $retArray=array('oid' => $oid, 'mib' => null, 'name'=>null,'type'=>null); |
| 129 | 136 | $dbconn = $this->db->getConnection(); |
| 130 | 137 | |
@@ -162,8 +169,7 @@ discard block |
||
| 162 | 169 | { |
| 163 | 170 | $retArray['type']=$matches[1]; |
| 164 | 171 | $retArray['type_enum']=$matches[2]; |
| 165 | - } |
|
| 166 | - else |
|
| 172 | + } else |
|
| 167 | 173 | { |
| 168 | 174 | $retArray['type']=$translate; |
| 169 | 175 | $retArray['type_enum']=''; |
@@ -229,8 +235,7 @@ discard block |
||
| 229 | 235 | if ($oid==null) |
| 230 | 236 | { |
| 231 | 237 | $where="c.id = '$id'"; |
| 232 | - } |
|
| 233 | - else |
|
| 238 | + } else |
|
| 234 | 239 | { |
| 235 | 240 | $where="c.oid = '$oid'"; |
| 236 | 241 | } |