Passed
Push — master ( d44cfc...57a389 )
by Patrick
02:07
created
library/Trapdirector/TrapsActions/TrapDBQuery.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
     {
26 26
         // TODO Check for rule consistency
27 27
         
28
-        $dbConn = $this->getDbConn();
28
+        $dbConn=$this->getDbConn();
29 29
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
30 30
         // Add last modified date = creation date and username
31
-        $params['created'] = new Zend_Db_Expr('NOW()');
32
-        $params['modified'] = new 	Zend_Db_Expr('NOW()');
33
-        $params['modifier'] = $this->Auth()->getUser()->getUsername();
31
+        $params['created']=new Zend_Db_Expr('NOW()');
32
+        $params['modified']=new 	Zend_Db_Expr('NOW()');
33
+        $params['modifier']=$this->Auth()->getUser()->getUsername();
34 34
         
35 35
         $query=$dbConn->insert(
36 36
             $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
37 37
             $params
38 38
             );
39
-        if($query==false)
39
+        if ($query == false)
40 40
         {
41 41
             return null;
42 42
         }
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
      *   @param integer $ruleID : rule id in db
49 49
      *	@return array affected rows
50 50
      */
51
-    public function updateHandlerRule($params,$ruleID)
51
+    public function updateHandlerRule($params, $ruleID)
52 52
     {
53 53
         // TODO Check for rule consistency
54
-        $dbConn = $this->getDbConn();
54
+        $dbConn=$this->getDbConn();
55 55
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
56 56
         // Add last modified date = creation date and username
57
-        $params['modified'] = new 	Zend_Db_Expr('NOW()');
58
-        $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
57
+        $params['modified']=new 	Zend_Db_Expr('NOW()');
58
+        $params['modifier']=$this->getTrapCtrl()->Auth()->getUser()->getUsername();
59 59
         
60 60
         $numRows=$dbConn->update(
61 61
             $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
      */
71 71
     public function deleteRule($ruleID)
72 72
     {
73
-        if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id');  }
73
+        if (!preg_match('/^[0-9]+$/', $ruleID)) { throw new Exception('Invalid id'); }
74 74
         
75
-        $dbConn = $this->getDbConn();
75
+        $dbConn=$this->getDbConn();
76 76
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
77 77
         
78 78
         $query=$dbConn->delete(
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
      *	@param $ipAddr string source IP (v4 or v6)
87 87
      *	@param $oid string oid
88 88
      */
89
-    public function deleteTrap($ipAddr,$oid)
89
+    public function deleteTrap($ipAddr, $oid)
90 90
     {
91 91
         
92
-        $dbConn = $this->getDbConn();
92
+        $dbConn=$this->getDbConn();
93 93
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
94 94
         $condition=null;
95 95
         if ($ipAddr != null)
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
         }
99 99
         if ($oid != null)
100 100
         {
101
-            $condition=($condition===null)?'':$condition.' AND ';
101
+            $condition=($condition === null) ? '' : $condition.' AND ';
102 102
             $condition.="trap_oid='$oid'";
103 103
         }
104
-        if($condition === null) return null;
104
+        if ($condition === null) return null;
105 105
         $query=$dbConn->delete(
106 106
             $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
107 107
             $condition
@@ -115,10 +115,10 @@  discard block
 block discarded – undo
115 115
      *	@param $ipAddr string source IP (v4 or v6)
116 116
      *	@param $oid string oid
117 117
      */
118
-    public function countTrap($ipAddr,$oid)
118
+    public function countTrap($ipAddr, $oid)
119 119
     {
120 120
         
121
-        $dbConn = $this->getDbConn();
121
+        $dbConn=$this->getDbConn();
122 122
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
123 123
         
124 124
         $condition=null;
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
         }
129 129
         if ($oid != null)
130 130
         {
131
-            $condition=($condition===null)?'':$condition.' AND ';
131
+            $condition=($condition === null) ? '' : $condition.' AND ';
132 132
             $condition.="trap_oid='$oid'";
133 133
         }
134
-        if($condition === null) return 0;
134
+        if ($condition === null) return 0;
135 135
         $query=$dbConn->select()
136 136
             ->from(
137 137
                 $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
@@ -147,28 +147,28 @@  discard block
 block discarded – undo
147 147
     public function getDBConfigValue($element)
148 148
     {
149 149
         
150
-        $dbConn = $this->getDbConn();
150
+        $dbConn=$this->getDbConn();
151 151
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
152 152
         
153 153
         $query=$dbConn->select()
154 154
         ->from(
155 155
             $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
156 156
             array('value'=>'value'))
157
-            ->where('name=?',$element);
157
+            ->where('name=?', $element);
158 158
             $returnRow=$dbConn->fetchRow($query);
159
-            if ($returnRow==null)  // value does not exists
159
+            if ($returnRow == null)  // value does not exists
160 160
             {
161 161
                 $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
162
-                if ( ! isset($default[$element])) return null; // no default and not value
162
+                if (!isset($default[$element])) return null; // no default and not value
163 163
                 
164
-                $this->addDBConfigValue($element,$default[$element]);
164
+                $this->addDBConfigValue($element, $default[$element]);
165 165
                 return $default[$element];
166 166
             }
167 167
             if ($returnRow->value == null) // value id empty
168 168
             {
169 169
                 $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
170
-                if ( ! isset($default[$element])) return null; // no default and not value
171
-                $this->setDBConfigValue($element,$default[$element]);
170
+                if (!isset($default[$element])) return null; // no default and not value
171
+                $this->setDBConfigValue($element, $default[$element]);
172 172
                 return $default[$element];
173 173
             }
174 174
             return $returnRow->value;
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
      *   @param string $value : value
180 180
      */
181 181
     
182
-    public function addDBConfigValue($element,$value)
182
+    public function addDBConfigValue($element, $value)
183 183
     {
184 184
         
185
-        $dbConn = $this->getDbConn();
185
+        $dbConn=$this->getDbConn();
186 186
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
187 187
         
188 188
         $query=$dbConn->insert(
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
      *	@param string $element : name of config element
200 200
      *   @param string $value : value
201 201
      */
202
-    public function setDBConfigValue($element,$value)
202
+    public function setDBConfigValue($element, $value)
203 203
     {
204 204
         
205
-        $dbConn = $this->getDbConn();
205
+        $dbConn=$this->getDbConn();
206 206
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
207 207
         
208 208
         $query=$dbConn->update(
Please login to merge, or discard this patch.