@@ 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 |
@@ 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 |
@@ 82-109 (lines=28) @@ | ||
79 | * |
|
80 | * @return array|string |
|
81 | */ |
|
82 | public function escape($data, bool $specialchars = false){ |
|
83 | ||
84 | if(is_array($data)){ |
|
85 | ||
86 | foreach($data as $key => $value){ |
|
87 | $data[$key] = $this->escape($value, $specialchars); |
|
88 | } |
|
89 | ||
90 | } |
|
91 | else if($data instanceof \stdClass){ |
|
92 | ||
93 | foreach($data as $key => $value){ |
|
94 | $data->{$key} = $this->escape($value, $specialchars); |
|
95 | } |
|
96 | ||
97 | } |
|
98 | else{ |
|
99 | ||
100 | if($specialchars){ |
|
101 | $data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false); |
|
102 | } |
|
103 | ||
104 | $data = $this->__escape($data); |
|
105 | } |
|
106 | ||
107 | return $data; |
|
108 | ||
109 | } |
|
110 | ||
111 | /** |
|
112 | * @param $callable |