@@ -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 | } |
@@ -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 | |
@@ -94,7 +94,9 @@ discard block |
||
| 94 | 94 | array('id' => 'id')) |
| 95 | 95 | ->where("oid = '".$trap."'") ; |
| 96 | 96 | $id=$dbconn->fetchRow($query); |
| 97 | - if ( ($id == null) || ! property_exists($id,'id') ) return null; |
|
| 97 | + if ( ($id == null) || ! property_exists($id,'id') ) { |
|
| 98 | + return null; |
|
| 99 | + } |
|
| 98 | 100 | |
| 99 | 101 | $query=$dbconn->select() |
| 100 | 102 | ->from( |
@@ -107,7 +109,9 @@ discard block |
||
| 107 | 109 | 'o.trap_id='.$id->id ) |
| 108 | 110 | ->where("o.object_id = c.id"); |
| 109 | 111 | $listObjects=$dbconn->fetchAll($query); |
| 110 | - if ( count($listObjects)==0 ) return null; |
|
| 112 | + if ( count($listObjects)==0 ) { |
|
| 113 | + return null; |
|
| 114 | + } |
|
| 111 | 115 | |
| 112 | 116 | foreach ($listObjects as $val) |
| 113 | 117 | { |
@@ -128,7 +132,10 @@ discard block |
||
| 128 | 132 | */ |
| 129 | 133 | public function translateOID($oid) |
| 130 | 134 | { |
| 131 | - if (!preg_match('/^\./',$oid)) $oid = '.' . $oid; // Add a leading '.' |
|
| 135 | + if (!preg_match('/^\./',$oid)) { |
|
| 136 | + $oid = '.' . $oid; |
|
| 137 | + } |
|
| 138 | + // Add a leading '.' |
|
| 132 | 139 | $retArray=array('oid' => $oid, 'mib' => null, 'name'=>null,'type'=>null); |
| 133 | 140 | $dbconn = $this->db->getConnection(); |
| 134 | 141 | |
@@ -166,8 +173,7 @@ discard block |
||
| 166 | 173 | { |
| 167 | 174 | $retArray['type']=$matches[1]; |
| 168 | 175 | $retArray['type_enum']=$matches[2]; |
| 169 | - } |
|
| 170 | - else |
|
| 176 | + } else |
|
| 171 | 177 | { |
| 172 | 178 | $retArray['type']=$translate; |
| 173 | 179 | $retArray['type_enum']=''; |
@@ -233,8 +239,7 @@ discard block |
||
| 233 | 239 | if ($oid===null) |
| 234 | 240 | { |
| 235 | 241 | $where="c.id = '$id'"; |
| 236 | - } |
|
| 237 | - else |
|
| 242 | + } else |
|
| 238 | 243 | { |
| 239 | 244 | $where="c.oid = '$oid'"; |
| 240 | 245 | } |
@@ -68,7 +68,9 @@ |
||
| 68 | 68 | switch ($outputType) |
| 69 | 69 | { |
| 70 | 70 | case 'file': |
| 71 | - if ($outputFile == null) throw new Exception("File logging without file !"); |
|
| 71 | + if ($outputFile == null) { |
|
| 72 | + throw new Exception("File logging without file !"); |
|
| 73 | + } |
|
| 72 | 74 | $this->setFile($outputFile); |
| 73 | 75 | $this->setDestination('file'); |
| 74 | 76 | break; |
@@ -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 | return; |
@@ -109,8 +110,7 @@ discard block |
||
| 109 | 110 | ->from($this->moduleConfig->getTrapDataTableName(),$data_elmts) |
| 110 | 111 | ->where('trap_id=?',$trapid); |
| 111 | 112 | $trapDetail=$db->fetchAll($query); |
| 112 | - } |
|
| 113 | - catch (Exception $e) |
|
| 113 | + } catch (Exception $e) |
|
| 114 | 114 | { |
| 115 | 115 | $this->displayExitError('Trap detail',$e->getMessage()); |
| 116 | 116 | } |
@@ -118,8 +118,7 @@ discard block |
||
| 118 | 118 | if ($trapDetail == null ) |
| 119 | 119 | { |
| 120 | 120 | $this->view->data=false; |
| 121 | - } |
|
| 122 | - else |
|
| 121 | + } else |
|
| 123 | 122 | { |
| 124 | 123 | $this->view->data=true; |
| 125 | 124 | // Store result in array. |
@@ -205,8 +204,7 @@ discard block |
||
| 205 | 204 | $ip=$postData['IP']; |
| 206 | 205 | $oid=$postData['OID']; |
| 207 | 206 | $action=$postData['action']; |
| 208 | - } |
|
| 209 | - else |
|
| 207 | + } else |
|
| 210 | 208 | { |
| 211 | 209 | $this->_helper->json(array('status'=>'Missing variables')); |
| 212 | 210 | return; |
@@ -64,8 +64,7 @@ discard block |
||
| 64 | 64 | if ($pid == 1) |
| 65 | 65 | { |
| 66 | 66 | $trap->setLogging($logLevel,'display'); |
| 67 | - } |
|
| 68 | - else |
|
| 67 | + } else |
|
| 69 | 68 | { // use default display TODO : if default is 'display' son process will be killed at first output.... |
| 70 | 69 | if ($pid != 0) |
| 71 | 70 | { |
@@ -74,8 +73,7 @@ discard block |
||
| 74 | 73 | fclose($file); |
| 75 | 74 | echo "OK : process $pid in bckground"; |
| 76 | 75 | return 0; |
| 77 | - } |
|
| 78 | - else |
|
| 76 | + } else |
|
| 79 | 77 | { // son process : close all file descriptors and go to a new session |
| 80 | 78 | fclose($file); |
| 81 | 79 | // $sid = posix_setsid(); |
@@ -85,8 +83,7 @@ discard block |
||
| 85 | 83 | try |
| 86 | 84 | { |
| 87 | 85 | $trap->mibClass->update_mib_database(false,$forceCheck); |
| 88 | - } |
|
| 89 | - catch (Exception $e) |
|
| 86 | + } catch (Exception $e) |
|
| 90 | 87 | { |
| 91 | 88 | $trap->trapLog('Error in updating : ' . $e->getMessage(),2); |
| 92 | 89 | } |
@@ -103,8 +100,7 @@ discard block |
||
| 103 | 100 | $trap->mibClass->update_mib_database(true,$forceCheck); |
| 104 | 101 | echo "Done\n"; |
| 105 | 102 | |
| 106 | - } |
|
| 107 | - catch (Exception $e) |
|
| 103 | + } catch (Exception $e) |
|
| 108 | 104 | { |
| 109 | 105 | echo 'Error in updating : ' . $e->getMessage(); |
| 110 | 106 | } |
@@ -147,8 +143,7 @@ discard block |
||
| 147 | 143 | $Config->getMIBCacheTableName(), |
| 148 | 144 | 'id>0'); |
| 149 | 145 | echo 'Deleted '. $query . " traps and objects\n"; |
| 150 | - } |
|
| 151 | - catch (Exception $e) |
|
| 146 | + } catch (Exception $e) |
|
| 152 | 147 | { |
| 153 | 148 | echo 'Error in DB : ' . $e->getMessage(); |
| 154 | 149 | } |