@@ 123-149 (lines=27) @@ | ||
120 | * |
|
121 | * @return array|string array or string. escaped. obviously. |
|
122 | */ |
|
123 | public function escape($data, bool $specialchars = false){ |
|
124 | ||
125 | if(is_array($data)){ |
|
126 | ||
127 | foreach($data as $key => $value){ |
|
128 | $data[$key] = $this->escape($value, $specialchars); |
|
129 | } |
|
130 | ||
131 | } |
|
132 | else if(is_object($data)){ |
|
133 | ||
134 | foreach($data as $key => $value){ |
|
135 | $data->{$key} = $this->escape($value, $specialchars); |
|
136 | } |
|
137 | ||
138 | } |
|
139 | else{ |
|
140 | ||
141 | if($specialchars){ |
|
142 | $data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false); |
|
143 | } |
|
144 | ||
145 | $data = $this->db->real_escape_string($data); |
|
146 | } |
|
147 | ||
148 | return $data; |
|
149 | } |
|
150 | ||
151 | /** |
|
152 | * Basic SQL query for non prepared statements |
@@ 157-183 (lines=27) @@ | ||
154 | * |
|
155 | * @return array|string array or string. escaped. obviously. |
|
156 | */ |
|
157 | public function escape($data, bool $specialchars = false){ |
|
158 | ||
159 | if(is_array($data)){ |
|
160 | ||
161 | foreach($data as $key => $value){ |
|
162 | $data[$key] = $this->escape($value, $specialchars); |
|
163 | } |
|
164 | ||
165 | } |
|
166 | else if(is_object($data)){ |
|
167 | ||
168 | foreach($data as $key => $value){ |
|
169 | $data->{$key} = $this->escape($value, $specialchars); |
|
170 | } |
|
171 | ||
172 | } |
|
173 | else{ |
|
174 | ||
175 | if($specialchars){ |
|
176 | $data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false); |
|
177 | } |
|
178 | ||
179 | $data = $this->db->quote($data); |
|
180 | } |
|
181 | ||
182 | return $data; |
|
183 | } |
|
184 | ||
185 | /** |
|
186 | * @param \PDOStatement $stmt |
@@ 104-130 (lines=27) @@ | ||
101 | * |
|
102 | * @return array|string array or string. escaped. obviously. |
|
103 | */ |
|
104 | public function escape($data, bool $specialchars = false){ |
|
105 | ||
106 | if(is_array($data)){ |
|
107 | ||
108 | foreach($data as $key => $value){ |
|
109 | $data[$key] = $this->escape($value, $specialchars); |
|
110 | } |
|
111 | ||
112 | } |
|
113 | else if(is_object($data)){ |
|
114 | ||
115 | foreach($data as $key => $value){ |
|
116 | $data->{$key} = $this->escape($value, $specialchars); |
|
117 | } |
|
118 | ||
119 | } |
|
120 | else{ |
|
121 | ||
122 | if($specialchars){ |
|
123 | $data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false); |
|
124 | } |
|
125 | ||
126 | $data = pg_escape_string($this->db, $data); |
|
127 | } |
|
128 | ||
129 | return $data; |
|
130 | } |
|
131 | ||
132 | /** |
|
133 | * Basic SQL query for non prepared statements |
@@ 95-121 (lines=27) @@ | ||
92 | * |
|
93 | * @return array|string array or string. escaped. obviously. |
|
94 | */ |
|
95 | public function escape($data, bool $specialchars = false){ |
|
96 | ||
97 | if(is_array($data)){ |
|
98 | ||
99 | foreach($data as $key => $value){ |
|
100 | $data[$key] = $this->escape($value, $specialchars); |
|
101 | } |
|
102 | ||
103 | } |
|
104 | else if(is_object($data)){ |
|
105 | ||
106 | foreach($data as $key => $value){ |
|
107 | $data->{$key} = $this->escape($value, $specialchars); |
|
108 | } |
|
109 | ||
110 | } |
|
111 | else{ |
|
112 | ||
113 | if($specialchars){ |
|
114 | $data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false); |
|
115 | } |
|
116 | ||
117 | $data = SQLite3::escapeString($data); |
|
118 | } |
|
119 | ||
120 | return $data; |
|
121 | } |
|
122 | ||
123 | /** |
|
124 | * Basic SQL query for non prepared statements |