This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||||
2 | |||||
3 | namespace XoopsModules\Xfguestbook; |
||||
4 | |||||
5 | /* |
||||
6 | * You may not change or alter any portion of this comment or credits |
||||
7 | * of supporting developers from this source code or any supporting source code |
||||
8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||
9 | * |
||||
10 | * This program is distributed in the hope that it will be useful, |
||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||
13 | */ |
||||
14 | |||||
15 | /** |
||||
16 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||||
17 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||||
18 | * @package |
||||
19 | * @since |
||||
20 | * @author XOOPS Development Team |
||||
21 | */ |
||||
22 | |||||
23 | /** |
||||
24 | * Class MessageHandler |
||||
25 | */ |
||||
26 | class MessageHandler extends \XoopsPersistableObjectHandler |
||||
27 | { |
||||
28 | /** @var \XoopsMySQLDatabase $db */ |
||||
29 | public $db; |
||||
30 | |||||
31 | /** |
||||
32 | * MessageHandler constructor. |
||||
33 | * @param \XoopsDatabase|null $db |
||||
34 | */ |
||||
35 | public function __construct(\XoopsDatabase $db = null) |
||||
36 | { |
||||
37 | $this->db = $db; |
||||
38 | } |
||||
39 | |||||
40 | /** |
||||
41 | * @param bool $isNew |
||||
42 | * @return Message |
||||
43 | */ |
||||
44 | public function create($isNew = true) |
||||
45 | { |
||||
46 | return new Message(); |
||||
47 | } |
||||
48 | |||||
49 | /** |
||||
50 | * @param int|null $id |
||||
51 | * @param null $fields |
||||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||||
52 | * @return bool|string |
||||
53 | */ |
||||
54 | public function get($id = null, $fields = null) |
||||
55 | { |
||||
56 | $id = (int)$id; |
||||
57 | if ($id > 0) { |
||||
58 | $sql = 'SELECT * FROM ' . $this->db->prefix('xfguestbook_msg') . ' WHERE msg_id=' . $id; |
||||
59 | if (!$result = $this->db->query($sql)) { |
||||
60 | return false; |
||||
61 | } |
||||
62 | $numrows = $this->db->getRowsNum($result); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type true ; however, parameter $result of XoopsMySQLDatabase::getRowsNum() does only seem to accept mysqli_result , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
63 | if (1 == $numrows) { |
||||
64 | $msg = new Message(); |
||||
65 | $msg->assignVars($this->db->fetchArray($result)); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type true ; however, parameter $result of XoopsMySQLDatabase::fetchArray() does only seem to accept mysqli_result , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
66 | |||||
67 | return $msg; |
||||
0 ignored issues
–
show
|
|||||
68 | } |
||||
69 | } |
||||
70 | |||||
71 | return false; |
||||
72 | } |
||||
73 | |||||
74 | /** |
||||
75 | * @param \XoopsObject $msg |
||||
76 | * @param bool $force |
||||
77 | * @return bool |
||||
78 | */ |
||||
79 | public function insert(\XoopsObject $msg, $force = true) |
||||
80 | { |
||||
81 | if (Message::class !== \get_class($msg)) { |
||||
82 | return false; |
||||
83 | } |
||||
84 | if (!$msg->cleanVars()) { |
||||
85 | return false; |
||||
86 | } |
||||
87 | foreach ($msg->cleanVars as $k => $v) { |
||||
88 | ${$k} = $v; |
||||
89 | } |
||||
90 | if (empty($msg_id)) { |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
91 | $msg_id = $this->db->genId('xfguestbook_msg_msg_id_seq'); |
||||
92 | $sql = 'INSERT INTO ' |
||||
93 | . $this->db->prefix('xfguestbook_msg') |
||||
94 | . ' (msg_id, user_id, uname, title, message, note, post_time, email, url, poster_ip, moderate, gender, country, photo, flagdir, other) VALUES (' |
||||
95 | . $msg_id |
||||
96 | . ',' |
||||
97 | . $user_id |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
98 | . ', ' |
||||
99 | . $this->db->quoteString($uname) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
100 | . ', ' |
||||
101 | . $this->db->quoteString($title) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
102 | . ', ' |
||||
103 | . $this->db->quoteString($message) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
104 | . ', ' |
||||
105 | . $this->db->quoteString($note) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
106 | . ', ' |
||||
107 | . $post_time |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
108 | . ', ' |
||||
109 | . $this->db->quoteString($email) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
110 | . ', ' |
||||
111 | . $this->db->quoteString($url) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
112 | . ', ' |
||||
113 | . $this->db->quoteString($poster_ip) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
114 | . ', ' |
||||
115 | . $moderate |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
116 | . ', ' |
||||
117 | . $this->db->quoteString($gender) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
118 | . ', ' |
||||
119 | . $this->db->quoteString($country) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
120 | . ', ' |
||||
121 | . $this->db->quoteString($photo) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
122 | . ', ' |
||||
123 | . $this->db->quoteString($flagdir) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
124 | . ', ' |
||||
125 | . $this->db->quoteString($other) |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
126 | . ')'; |
||||
127 | } else { |
||||
128 | $sql = 'UPDATE ' |
||||
129 | . $this->db->prefix('xfguestbook_msg') |
||||
130 | . ' SET user_id=' |
||||
131 | . $user_id |
||||
132 | . ', uname=' |
||||
133 | . $this->db->quoteString($uname) |
||||
134 | . ', title=' |
||||
135 | . $this->db->quoteString($title) |
||||
136 | . ', message=' |
||||
137 | . $this->db->quoteString($message) |
||||
138 | . ', note=' |
||||
139 | . $this->db->quoteString($note) |
||||
140 | . ', email=' |
||||
141 | . $this->db->quoteString($email) |
||||
142 | . ', url=' |
||||
143 | . $this->db->quoteString($url) |
||||
144 | . ', moderate=' |
||||
145 | . $moderate |
||||
146 | . ', gender=' |
||||
147 | . $this->db->quoteString($gender) |
||||
148 | . ', country=' |
||||
149 | . $this->db->quoteString($country) |
||||
150 | . ', photo=' |
||||
151 | . $this->db->quoteString($photo) |
||||
152 | . ', flagdir=' |
||||
153 | . $this->db->quoteString($flagdir) |
||||
154 | . ', other=' |
||||
155 | . $this->db->quoteString($other) |
||||
156 | . ' WHERE msg_id=' |
||||
157 | . $msg_id; |
||||
158 | } |
||||
159 | if (!$result = $this->db->queryF($sql)) { |
||||
0 ignored issues
–
show
|
|||||
160 | return false; |
||||
161 | } |
||||
162 | if (empty($msg_id)) { |
||||
163 | $msg_id = $this->db->getInsertId(); |
||||
164 | } |
||||
165 | $msg->assignVar('msg_id', $msg_id); |
||||
166 | |||||
167 | return $msg_id; |
||||
168 | } |
||||
169 | |||||
170 | /** |
||||
171 | * @param \XoopsObject $msg |
||||
172 | * @param bool $force |
||||
173 | * @return bool |
||||
174 | */ |
||||
175 | public function delete(\XoopsObject $msg, $force = false) |
||||
176 | { |
||||
177 | global $xoopsModule; |
||||
178 | if (Message::class !== \get_class($msg)) { |
||||
179 | return false; |
||||
180 | } |
||||
181 | $sql = \sprintf('DELETE FROM `%s` WHERE msg_id = %u', $this->db->prefix('xfguestbook_msg'), $msg->getVar('msg_id')); |
||||
0 ignored issues
–
show
It seems like
$msg->getVar('msg_id') can also be of type array and array ; however, parameter $args of sprintf() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
182 | if (isset($this->commentstable) && '' !== $this->commentstable) { |
||||
183 | \xoops_comment_delete($xoopsModule->getVar('mid'), $msg_id); |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
184 | } |
||||
185 | |||||
186 | if (!$result = $this->db->query($sql)) { |
||||
0 ignored issues
–
show
|
|||||
187 | return false; |
||||
188 | } |
||||
189 | |||||
190 | return true; |
||||
191 | } |
||||
192 | |||||
193 | /** |
||||
194 | * @param null|\CriteriaElement|\CriteriaCompo $criteria |
||||
195 | * @param bool $id_as_key |
||||
196 | * @param bool $as_object |
||||
197 | * @return array |
||||
198 | */ |
||||
199 | public function &getObjects(\CriteriaElement $criteria = null, $id_as_key = false, $as_object = true)//getObjects(\CriteriaElement $criteria = null) |
||||
200 | { |
||||
201 | $ret = []; |
||||
202 | $limit = $start = 0; |
||||
203 | $sql = 'SELECT * FROM ' . $this->db->prefix('xfguestbook_msg'); |
||||
204 | if (null !== $criteria && $criteria instanceof \CriteriaElement) { |
||||
205 | $sql .= ' ' . $criteria->renderWhere(); |
||||
0 ignored issues
–
show
The method
renderWhere() does not exist on CriteriaElement . Did you maybe mean render() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
206 | $sort = ('' !== $criteria->getSort()) ? $criteria->getSort() : 'msg_id'; |
||||
207 | $sql .= ' ORDER BY ' . $sort . ' ' . $criteria->getOrder(); |
||||
208 | $limit = $criteria->getLimit(); |
||||
209 | $start = $criteria->getStart(); |
||||
210 | } |
||||
211 | $result = $this->db->query($sql, $limit, $start); |
||||
212 | if (!$result) { |
||||
213 | return $ret; |
||||
214 | } |
||||
215 | while (false !== ($myrow = $this->db->fetchArray($result))) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type true ; however, parameter $result of XoopsMySQLDatabase::fetchArray() does only seem to accept mysqli_result , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
216 | $msg = new Message(); |
||||
217 | $msg->assignVars($myrow); |
||||
218 | $ret[] = $msg; |
||||
219 | unset($msg); |
||||
220 | } |
||||
221 | |||||
222 | return $ret; |
||||
223 | } |
||||
224 | |||||
225 | /** |
||||
226 | * @param null|\CriteriaElement|\CriteriaCompo $criteria |
||||
227 | * @return int |
||||
228 | */ |
||||
229 | public function countMsg(\CriteriaElement $criteria = null) |
||||
230 | { |
||||
231 | $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('xfguestbook_msg'); |
||||
232 | if (null !== $criteria && $criteria instanceof \CriteriaElement) { |
||||
233 | $sql .= ' ' . $criteria->renderWhere(); |
||||
234 | } |
||||
235 | if (!$result = $this->db->query($sql)) { |
||||
236 | return 0; |
||||
237 | } |
||||
238 | [$count] = $this->db->fetchRow($result); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type true ; however, parameter $result of XoopsMySQLDatabase::fetchRow() does only seem to accept mysqli_result , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
239 | |||||
240 | return $count; |
||||
241 | } |
||||
242 | |||||
243 | /** |
||||
244 | * @param null|\CriteriaElement|\CriteriaCompo $criteria |
||||
245 | * @return array|bool |
||||
246 | */ |
||||
247 | public function countMsgByCountry(\CriteriaElement $criteria = null) |
||||
248 | { |
||||
249 | $arr = []; |
||||
250 | $sql = 'SELECT country, flagdir FROM ' . $this->db->prefix('xfguestbook_msg'); |
||||
251 | if (null !== $criteria && $criteria instanceof \CriteriaElement) { |
||||
252 | $sql .= ' ' . $criteria->renderWhere(); |
||||
253 | } |
||||
254 | if (!$result = $this->db->query($sql)) { |
||||
255 | return false; |
||||
256 | } |
||||
257 | while (list($country, $flagdir) = $this->db->fetchRow($result)) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type true ; however, parameter $result of XoopsMySQLDatabase::fetchRow() does only seem to accept mysqli_result , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
258 | $arr[] = $flagdir . '/' . $country; |
||||
259 | } |
||||
260 | $ret = \array_count_values($arr); |
||||
261 | \arsort($ret); |
||||
262 | |||||
263 | return $ret; |
||||
264 | } |
||||
265 | |||||
266 | /** |
||||
267 | * @param \CriteriaElement|\CriteriaCompo|null $criteria |
||||
268 | * @return array|bool |
||||
269 | */ |
||||
270 | public function countMsgByGender(\CriteriaElement $criteria = null) |
||||
271 | { |
||||
272 | $arr = []; |
||||
273 | $sql = 'SELECT gender FROM ' . $this->db->prefix('xfguestbook_msg'); |
||||
274 | if (null !== $criteria && $criteria instanceof \CriteriaElement) { |
||||
275 | $sql .= ' ' . $criteria->renderWhere(); |
||||
276 | } |
||||
277 | if (!$result = $this->db->query($sql)) { |
||||
278 | return false; |
||||
279 | } |
||||
280 | while (list($gender) = $this->db->fetchRow($result)) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type true ; however, parameter $result of XoopsMySQLDatabase::fetchRow() does only seem to accept mysqli_result , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
281 | $arr[] = $gender; |
||||
282 | } |
||||
283 | $ret = \array_count_values($arr); |
||||
284 | |||||
285 | return $ret; |
||||
286 | } |
||||
287 | |||||
288 | /** |
||||
289 | * @param null|\CriteriaElement|\CriteriaCompo $criteria |
||||
290 | * @return array|int |
||||
291 | */ |
||||
292 | public function getMsgImg(\CriteriaElement $criteria = null) |
||||
293 | { |
||||
294 | $arr = []; |
||||
295 | $sql = 'SELECT photo FROM ' . $this->db->prefix('xfguestbook_msg') . " WHERE `photo` LIKE 'msg_%'"; |
||||
296 | if (null !== $criteria && $criteria instanceof \CriteriaElement) { |
||||
297 | $sql .= ' ' . $criteria->renderWhere(); |
||||
298 | } |
||||
299 | if (!$result = $this->db->query($sql)) { |
||||
300 | return 0; |
||||
301 | } |
||||
302 | while (list($photo) = $this->db->fetchRow($result)) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type true ; however, parameter $result of XoopsMySQLDatabase::fetchRow() does only seem to accept mysqli_result , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
303 | $arr[] = $photo; |
||||
304 | } |
||||
305 | |||||
306 | return $arr; |
||||
307 | } |
||||
308 | } |
||||
309 |