Passed
Push — master ( e15d84...f89732 )
by Patrick
02:08
created
library/Trapdirector/TrapsActions/TrapDBQuery.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
     {
34 34
         // TODO Check for rule consistency
35 35
         
36
-        $dbConn = $this->getDbConn();
36
+        $dbConn=$this->getDbConn();
37 37
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
38 38
         // Add last modified date = creation date and username
39
-        $params['created'] = new Zend_Db_Expr('NOW()');
40
-        $params['modified'] = new 	Zend_Db_Expr('NOW()');
41
-        $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
39
+        $params['created']=new Zend_Db_Expr('NOW()');
40
+        $params['modified']=new 	Zend_Db_Expr('NOW()');
41
+        $params['modifier']=$this->getTrapCtrl()->Auth()->getUser()->getUsername();
42 42
         
43 43
         $query=$dbConn->insert(
44 44
             $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
45 45
             $params
46 46
             );
47
-        if($query==false)
47
+        if ($query == false)
48 48
         {
49 49
             return null;
50 50
         }
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
      *   @param integer $ruleID : rule id in db
57 57
      *	@return array affected rows
58 58
      */
59
-    public function updateHandlerRule($params,$ruleID)
59
+    public function updateHandlerRule($params, $ruleID)
60 60
     {
61 61
         // TODO Check for rule consistency
62
-        $dbConn = $this->getDbConn();
62
+        $dbConn=$this->getDbConn();
63 63
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
64 64
         // Add last modified date = creation date and username
65
-        $params['modified'] = new 	Zend_Db_Expr('NOW()');
66
-        $params['modifier'] = $this->getTrapCtrl()->Auth()->getUser()->getUsername();
65
+        $params['modified']=new 	Zend_Db_Expr('NOW()');
66
+        $params['modifier']=$this->getTrapCtrl()->Auth()->getUser()->getUsername();
67 67
         
68 68
         $numRows=$dbConn->update(
69 69
             $this->getTrapCtrl()->getModuleConfig()->getTrapRuleName(),
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function deleteRule($ruleID)
80 80
     {
81
-        if (!preg_match('/^[0-9]+$/',$ruleID)) { throw new Exception('Invalid id');  }
81
+        if (!preg_match('/^[0-9]+$/', $ruleID)) { throw new Exception('Invalid id'); }
82 82
         
83
-        $dbConn = $this->getDbConn();
83
+        $dbConn=$this->getDbConn();
84 84
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
85 85
         
86 86
         $query=$dbConn->delete(
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
      *	@param $ipAddr string source IP (v4 or v6)
95 95
      *	@param $oid string oid
96 96
      */
97
-    public function deleteTrap($ipAddr,$oid)
97
+    public function deleteTrap($ipAddr, $oid)
98 98
     {
99 99
         
100
-        $dbConn = $this->getDbConn();
100
+        $dbConn=$this->getDbConn();
101 101
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
102 102
         $condition=null;
103 103
         if ($ipAddr != null)
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
         }
107 107
         if ($oid != null)
108 108
         {
109
-            $condition=($condition===null)?'':$condition.' AND ';
109
+            $condition=($condition === null) ? '' : $condition.' AND ';
110 110
             $condition.="trap_oid='$oid'";
111 111
         }
112
-        if($condition === null) return null;
112
+        if ($condition === null) return null;
113 113
         $query=$dbConn->delete(
114 114
             $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
115 115
             $condition
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
      *	@param $ipAddr string source IP (v4 or v6)
124 124
      *	@param $oid string oid
125 125
      */
126
-    public function countTrap($ipAddr,$oid)
126
+    public function countTrap($ipAddr, $oid)
127 127
     {
128 128
         
129
-        $dbConn = $this->getDbConn();
129
+        $dbConn=$this->getDbConn();
130 130
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
131 131
         
132 132
         $condition=null;
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
         }
137 137
         if ($oid != null)
138 138
         {
139
-            $condition=($condition===null)?'':$condition.' AND ';
139
+            $condition=($condition === null) ? '' : $condition.' AND ';
140 140
             $condition.="trap_oid='$oid'";
141 141
         }
142
-        if($condition === null) return 0;
142
+        if ($condition === null) return 0;
143 143
         $query=$dbConn->select()
144 144
             ->from(
145 145
                 $this->getTrapCtrl()->getModuleConfig()->getTrapTableName(),
@@ -155,28 +155,28 @@  discard block
 block discarded – undo
155 155
     public function getDBConfigValue($element)
156 156
     {
157 157
         
158
-        $dbConn = $this->getDbConn();
158
+        $dbConn=$this->getDbConn();
159 159
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
160 160
         
161 161
         $query=$dbConn->select()
162 162
         ->from(
163 163
             $this->getTrapCtrl()->getModuleConfig()->getDbConfigTableName(),
164 164
             array('value'=>'value'))
165
-            ->where('name=?',$element);
165
+            ->where('name=?', $element);
166 166
             $returnRow=$dbConn->fetchRow($query);
167
-            if ($returnRow==null)  // value does not exists
167
+            if ($returnRow == null)  // value does not exists
168 168
             {
169 169
                 $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
170
-                if ( ! isset($default[$element])) return null; // no default and not value
170
+                if (!isset($default[$element])) return null; // no default and not value
171 171
                 
172
-                $this->addDBConfigValue($element,$default[$element]);
172
+                $this->addDBConfigValue($element, $default[$element]);
173 173
                 return $default[$element];
174 174
             }
175 175
             if ($returnRow->value == null) // value id empty
176 176
             {
177 177
                 $default=$this->getTrapCtrl()->getModuleConfig()->getDBConfigDefaults();
178
-                if ( ! isset($default[$element])) return null; // no default and not value
179
-                $this->setDBConfigValue($element,$default[$element]);
178
+                if (!isset($default[$element])) return null; // no default and not value
179
+                $this->setDBConfigValue($element, $default[$element]);
180 180
                 return $default[$element];
181 181
             }
182 182
             return $returnRow->value;
@@ -187,10 +187,10 @@  discard block
 block discarded – undo
187 187
      *   @param string $value : value
188 188
      */
189 189
     
190
-    public function addDBConfigValue($element,$value)
190
+    public function addDBConfigValue($element, $value)
191 191
     {
192 192
         
193
-        $dbConn = $this->getDbConn();
193
+        $dbConn=$this->getDbConn();
194 194
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
195 195
         
196 196
         $query=$dbConn->insert(
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
      *	@param string $element : name of config element
208 208
      *   @param string $value : value
209 209
      */
210
-    public function setDBConfigValue($element,$value)
210
+    public function setDBConfigValue($element, $value)
211 211
     {
212 212
         
213
-        $dbConn = $this->getDbConn();
213
+        $dbConn=$this->getDbConn();
214 214
         if ($dbConn === null) throw new \ErrorException('uncatched db error');
215 215
         
216 216
         $query=$dbConn->update(
Please login to merge, or discard this patch.