@@ -54,8 +54,7 @@ |
||
| 54 | 54 | if (isset($params['name'])) |
| 55 | 55 | { |
| 56 | 56 | |
| 57 | - } |
|
| 58 | - else |
|
| 57 | + } else |
|
| 59 | 58 | { |
| 60 | 59 | |
| 61 | 60 | } |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | // TODO Check for rule consistency |
| 36 | 36 | |
| 37 | 37 | $dbConn = $this->getDbConn(); |
| 38 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 38 | + if ($dbConn === null) { |
|
| 39 | + throw new \ErrorException('uncatched db error'); |
|
| 40 | + } |
|
| 39 | 41 | // Add last modified date = creation date and username |
| 40 | 42 | $params['created'] = new Zend_Db_Expr('NOW()'); |
| 41 | 43 | $params['modified'] = new Zend_Db_Expr('NOW()'); |
@@ -61,7 +63,9 @@ discard block |
||
| 61 | 63 | { |
| 62 | 64 | // TODO Check for rule consistency |
| 63 | 65 | $dbConn = $this->getDbConn(); |
| 64 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 66 | + if ($dbConn === null) { |
|
| 67 | + throw new \ErrorException('uncatched db error'); |
|
| 68 | + } |
|
| 65 | 69 | // Add last modified date = creation date and username |
| 66 | 70 | $params['modified'] = new Zend_Db_Expr('NOW()'); |
| 67 | 71 | $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername(); |
@@ -82,7 +86,9 @@ discard block |
||
| 82 | 86 | if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id'); } |
| 83 | 87 | |
| 84 | 88 | $dbConn = $this->getDbConn(); |
| 85 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 89 | + if ($dbConn === null) { |
|
| 90 | + throw new \ErrorException('uncatched db error'); |
|
| 91 | + } |
|
| 86 | 92 | |
| 87 | 93 | $query=$dbConn->delete( |
| 88 | 94 | $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(), |
@@ -99,7 +105,9 @@ discard block |
||
| 99 | 105 | public function lastModification() |
| 100 | 106 | { |
| 101 | 107 | $dbConn = $this->getDbConn(); |
| 102 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 108 | + if ($dbConn === null) { |
|
| 109 | + throw new \ErrorException('uncatched db error'); |
|
| 110 | + } |
|
| 103 | 111 | |
| 104 | 112 | $query = $dbConn->select() |
| 105 | 113 | ->from( |
@@ -117,7 +125,9 @@ discard block |
||
| 117 | 125 | { |
| 118 | 126 | |
| 119 | 127 | $dbConn = $this->getDbConn(); |
| 120 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 128 | + if ($dbConn === null) { |
|
| 129 | + throw new \ErrorException('uncatched db error'); |
|
| 130 | + } |
|
| 121 | 131 | $condition=null; |
| 122 | 132 | if ($ipAddr != null) |
| 123 | 133 | { |
@@ -128,7 +138,9 @@ discard block |
||
| 128 | 138 | $condition=($condition===null)?'':$condition.' AND '; |
| 129 | 139 | $condition.="trap_oid='$oid'"; |
| 130 | 140 | } |
| 131 | - if($condition === null) return null; |
|
| 141 | + if($condition === null) { |
|
| 142 | + return null; |
|
| 143 | + } |
|
| 132 | 144 | $query=$dbConn->delete( |
| 133 | 145 | $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
| 134 | 146 | $condition |
@@ -146,7 +158,9 @@ discard block |
||
| 146 | 158 | { |
| 147 | 159 | |
| 148 | 160 | $dbConn = $this->getDbConn(); |
| 149 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 161 | + if ($dbConn === null) { |
|
| 162 | + throw new \ErrorException('uncatched db error'); |
|
| 163 | + } |
|
| 150 | 164 | |
| 151 | 165 | $condition=null; |
| 152 | 166 | if ($ipAddr != null) |
@@ -158,7 +172,9 @@ discard block |
||
| 158 | 172 | $condition=($condition===null)?'':$condition.' AND '; |
| 159 | 173 | $condition.="trap_oid='$oid'"; |
| 160 | 174 | } |
| 161 | - if($condition === null) return 0; |
|
| 175 | + if($condition === null) { |
|
| 176 | + return 0; |
|
| 177 | + } |
|
| 162 | 178 | $query=$dbConn->select() |
| 163 | 179 | ->from( |
| 164 | 180 | $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(), |
@@ -175,7 +191,9 @@ discard block |
||
| 175 | 191 | { |
| 176 | 192 | |
| 177 | 193 | $dbConn = $this->getDbConn(); |
| 178 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 194 | + if ($dbConn === null) { |
|
| 195 | + throw new \ErrorException('uncatched db error'); |
|
| 196 | + } |
|
| 179 | 197 | |
| 180 | 198 | $query=$dbConn->select() |
| 181 | 199 | ->from( |
@@ -183,18 +201,28 @@ discard block |
||
| 183 | 201 | array('value'=>'value')) |
| 184 | 202 | ->where('name=?',$element); |
| 185 | 203 | $returnRow=$dbConn->fetchRow($query); |
| 186 | - if ($returnRow==null) // value does not exists |
|
| 204 | + if ($returnRow==null) { |
|
| 205 | + // value does not exists |
|
| 187 | 206 | { |
| 188 | 207 | $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
| 189 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 208 | + } |
|
| 209 | + if ( ! isset($default[$element])) { |
|
| 210 | + return null; |
|
| 211 | + } |
|
| 212 | + // no default and not value |
|
| 190 | 213 | |
| 191 | 214 | $this->addDBConfigValue($element,$default[$element]); |
| 192 | 215 | return $default[$element]; |
| 193 | 216 | } |
| 194 | - if ($returnRow->value == null) // value id empty |
|
| 217 | + if ($returnRow->value == null) { |
|
| 218 | + // value id empty |
|
| 195 | 219 | { |
| 196 | 220 | $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults(); |
| 197 | - if ( ! isset($default[$element])) return null; // no default and not value |
|
| 221 | + } |
|
| 222 | + if ( ! isset($default[$element])) { |
|
| 223 | + return null; |
|
| 224 | + } |
|
| 225 | + // no default and not value |
|
| 198 | 226 | $this->setDBConfigValue($element,$default[$element]); |
| 199 | 227 | return $default[$element]; |
| 200 | 228 | } |
@@ -210,7 +238,9 @@ discard block |
||
| 210 | 238 | { |
| 211 | 239 | |
| 212 | 240 | $dbConn = $this->getDbConn(); |
| 213 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 241 | + if ($dbConn === null) { |
|
| 242 | + throw new \ErrorException('uncatched db error'); |
|
| 243 | + } |
|
| 214 | 244 | |
| 215 | 245 | $query=$dbConn->insert( |
| 216 | 246 | $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
@@ -230,7 +260,9 @@ discard block |
||
| 230 | 260 | { |
| 231 | 261 | |
| 232 | 262 | $dbConn = $this->getDbConn(); |
| 233 | - if ($dbConn === null) throw new \ErrorException('uncatched db error'); |
|
| 263 | + if ($dbConn === null) { |
|
| 264 | + throw new \ErrorException('uncatched db error'); |
|
| 265 | + } |
|
| 234 | 266 | |
| 235 | 267 | $query=$dbConn->update( |
| 236 | 268 | $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(), |
@@ -40,8 +40,7 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | $this->getLogging()->log($message,$log_level); |
| 42 | 42 | return false; |
| 43 | - } |
|
| 44 | - else |
|
| 43 | + } else |
|
| 45 | 44 | { |
| 46 | 45 | $option_var=$option_array[$option_category][$option_name]; |
| 47 | 46 | return true; |
@@ -54,9 +53,11 @@ discard block |
||
| 54 | 53 | protected function getDatabaseOptions() |
| 55 | 54 | { |
| 56 | 55 | // Database options |
| 57 | - if ($this->logSetup === false) // Only if logging was no setup in constructor |
|
| 56 | + if ($this->logSetup === false) { |
|
| 57 | + // Only if logging was no setup in constructor |
|
| 58 | 58 | { |
| 59 | 59 | $this->getDBConfigIfSet('log_level',$this->getLogging()->debugLevel); |
| 60 | + } |
|
| 60 | 61 | $this->getDBConfigIfSet('log_destination',$this->getLogging()->outputMode); |
| 61 | 62 | $this->getDBConfigIfSet('log_file',$this->getLogging()->outputFile); |
| 62 | 63 | } |
@@ -69,7 +70,9 @@ discard block |
||
| 69 | 70 | protected function getDBConfigIfSet($element,&$variable) |
| 70 | 71 | { |
| 71 | 72 | $value=$this->getDBConfig($element); |
| 72 | - if ($value != null) $variable=$value; |
|
| 73 | + if ($value != null) { |
|
| 74 | + $variable=$value; |
|
| 75 | + } |
|
| 73 | 76 | } |
| 74 | 77 | |
| 75 | 78 | /** |
@@ -106,8 +109,7 @@ discard block |
||
| 106 | 109 | { |
| 107 | 110 | $this->getLogging()->log('Unknown node status '.$nodeStatus.' : setting to MASTER',WARN); |
| 108 | 111 | $this->getTrapApi()->setStatusMaster(); |
| 109 | - } |
|
| 110 | - else |
|
| 112 | + } else |
|
| 111 | 113 | { |
| 112 | 114 | if ($this->getTrapApi()->getStatus() != TrapApi::MASTER) |
| 113 | 115 | { |
@@ -173,7 +175,10 @@ discard block |
||
| 173 | 175 | |
| 174 | 176 | $this->trapsDB = new Database($this->logging,$dbConfig[$dbTrapName],$this->dbPrefix); |
| 175 | 177 | |
| 176 | - if ($this->apiUse === true) return; // In case of API use, no IDO is necessary |
|
| 178 | + if ($this->apiUse === true) { |
|
| 179 | + return; |
|
| 180 | + } |
|
| 181 | + // In case of API use, no IDO is necessary |
|
| 177 | 182 | |
| 178 | 183 | // IDO Database |
| 179 | 184 | if (!array_key_exists('IDOdatabase',$trapConfig['config'])) |
@@ -47,8 +47,7 @@ |
||
| 47 | 47 | { |
| 48 | 48 | $query = $this->trapController->getUIDatabase()->lastModification(); |
| 49 | 49 | return array('lastModified' => $query); |
| 50 | - } |
|
| 51 | - catch (\ErrorException $e) |
|
| 50 | + } catch (\ErrorException $e) |
|
| 52 | 51 | { |
| 53 | 52 | return array('Error' => $e->getMessage()); |
| 54 | 53 | } |