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 declare(strict_types=1); |
||||
2 | |||||
3 | namespace XoopsModules\Adslight; |
||||
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 XOOPS Project (https://xoops.org) |
||||
17 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||||
18 | * @author XOOPS Development Team |
||||
19 | * @author Pascal Le Boustouller: original author ([email protected]) |
||||
20 | * @author Luc Bizet (www.frxoops.org) |
||||
21 | * @author jlm69 (www.jlmzone.com) |
||||
22 | * @author mamba (www.xoops.org) |
||||
23 | */ |
||||
24 | |||||
25 | use Xmf\Module\Admin; |
||||
26 | |||||
27 | /** |
||||
28 | * Class Tree |
||||
29 | */ |
||||
30 | class Tree |
||||
31 | { |
||||
32 | public $table; |
||||
33 | public $id; |
||||
34 | public $pid; |
||||
35 | public $order; |
||||
36 | public $title; |
||||
37 | /** |
||||
38 | * @var \XoopsMySQLDatabase |
||||
39 | */ |
||||
40 | public $db; |
||||
41 | |||||
42 | /** |
||||
43 | * @param $table_name |
||||
44 | * @param $id_name |
||||
45 | * @param $pid_name |
||||
46 | */ |
||||
47 | public function __construct( |
||||
48 | $table_name, |
||||
49 | $id_name, |
||||
50 | $pid_name |
||||
51 | ) { |
||||
52 | $this->db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||||
53 | $this->table = $table_name; |
||||
54 | $this->id = $id_name; |
||||
55 | $this->pid = $pid_name; |
||||
56 | $this->order = ''; |
||||
57 | $this->title = ''; |
||||
58 | } |
||||
59 | |||||
60 | /** |
||||
61 | * @param int $sel_id |
||||
62 | * @param string $order |
||||
63 | */ |
||||
64 | public function getFirstChild($sel_id, $order = ''): array |
||||
65 | { |
||||
66 | $arr = []; |
||||
67 | $sql = 'SELECT SQL_CACHE * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . ' '; |
||||
68 | |||||
69 | $categories = Utility::getMyItemIds('adslight_view'); |
||||
70 | if (\is_array($categories) && $categories !== []) { |
||||
71 | $sql .= ' AND ' . $this->pid . ' IN (' . \implode(',', $categories) . ') '; |
||||
72 | } |
||||
73 | |||||
74 | if ('' !== $order) { |
||||
75 | $sql .= " ORDER BY {$order}"; |
||||
76 | } |
||||
77 | |||||
78 | $result = $this->db->query($sql); |
||||
79 | if (!$this->db->isResultSet($result)) { |
||||
80 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), \E_USER_ERROR); |
||||
81 | } |
||||
82 | $count = $this->db->getRowsNum($result); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
83 | if (0 === $count) { |
||||
84 | return $arr; |
||||
85 | } |
||||
86 | while (false !== ($myrow = $this->db->fetchArray($result))) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
87 | $arr[] = $myrow; |
||||
88 | } |
||||
89 | |||||
90 | return $arr; |
||||
91 | } |
||||
92 | |||||
93 | /** |
||||
94 | * @param $sel_id |
||||
95 | * @return array |
||||
96 | */ |
||||
97 | public function getFirstChildId($sel_id): array |
||||
98 | { |
||||
99 | $idarray = []; |
||||
100 | $sel_id = (int)$sel_id; |
||||
101 | $sql = 'SELECT SQL_CACHE ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id; |
||||
102 | $result = $this->db->query($sql); |
||||
103 | if (!$this->db->isResultSet($result)) { |
||||
104 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), E_USER_ERROR); |
||||
105 | } |
||||
106 | |||||
107 | $categories = Utility::getMyItemIds('adslight_view'); |
||||
108 | if (\is_array($categories) && $categories !== []) { |
||||
109 | $result .= ' AND ' . $this->pid . ' IN (' . \implode(',', $categories) . ') '; |
||||
110 | } |
||||
111 | |||||
112 | $count = $this->db->getRowsNum($result); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean and string ; 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
![]() |
|||||
113 | if (0 === $count) { |
||||
114 | return $idarray; |
||||
115 | } |
||||
116 | while (false !== [$id] = $this->db->fetchRow($result)) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean and string ; 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
![]() |
|||||
117 | $idarray[] = $id; |
||||
118 | } |
||||
119 | |||||
120 | return $idarray; |
||||
121 | } |
||||
122 | |||||
123 | /** |
||||
124 | * @param $sel_id |
||||
125 | * @param string $order |
||||
126 | * @param array $idarray |
||||
127 | * @return array |
||||
128 | */ |
||||
129 | public function getAllChildId($sel_id, $order = '', $idarray = []): array |
||||
130 | { |
||||
131 | $sel_id = (int)$sel_id; |
||||
132 | $sql = 'SELECT SQL_CACHE ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id; |
||||
133 | |||||
134 | $categories = Utility::getMyItemIds('adslight_view'); |
||||
135 | if (\is_array($categories) && $categories !== []) { |
||||
136 | $sql .= ' AND ' . $this->pid . ' IN (' . \implode(',', $categories) . ') '; |
||||
137 | } |
||||
138 | |||||
139 | if ('' !== $order) { |
||||
140 | $sql .= " ORDER BY {$order}"; |
||||
141 | } |
||||
142 | $result = $this->db->query($sql); |
||||
143 | if (!$this->db->isResultSet($result)) { |
||||
144 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), \E_USER_ERROR); |
||||
145 | } |
||||
146 | $count = $this->db->getRowsNum($result); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
147 | if (0 === $count) { |
||||
148 | return $idarray; |
||||
149 | } |
||||
150 | while (false !== [$r_id] = $this->db->fetchRow($result)) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
151 | $idarray[] = $r_id; |
||||
152 | $idarray = $this->getAllChildId($r_id, $order, $idarray); |
||||
153 | } |
||||
154 | |||||
155 | return $idarray; |
||||
156 | } |
||||
157 | |||||
158 | /** |
||||
159 | * @param $sel_id |
||||
160 | * @param string $order |
||||
161 | * @param array $idarray |
||||
162 | * @return array |
||||
163 | */ |
||||
164 | public function getAllParentId($sel_id, $order = '', $idarray = []): array |
||||
165 | { |
||||
166 | $sql = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . (int)$sel_id; |
||||
167 | |||||
168 | $categories = Utility::getMyItemIds('adslight_view'); |
||||
169 | if (\is_array($categories) && $categories !== []) { |
||||
170 | $sql .= ' AND ' . $this->pid . ' IN (' . \implode(',', $categories) . ') '; |
||||
171 | } |
||||
172 | |||||
173 | if ('' !== $order) { |
||||
174 | $sql .= " ORDER BY {$order}"; |
||||
175 | } |
||||
176 | $result = $this->db->query($sql); |
||||
177 | if (!$this->db->isResultSet($result)) { |
||||
178 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), E_USER_ERROR); |
||||
179 | } |
||||
180 | [$r_id] = $this->db->fetchRow($result); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
181 | if (0 === $r_id) { |
||||
182 | return $idarray; |
||||
183 | } |
||||
184 | $idarray[] = $r_id; |
||||
185 | |||||
186 | return $this->getAllParentId($r_id, $order, $idarray); |
||||
187 | } |
||||
188 | |||||
189 | /** |
||||
190 | * @param $sel_id |
||||
191 | * @param $title |
||||
192 | * @param string $path |
||||
193 | * @return string |
||||
194 | */ |
||||
195 | public function getPathFromId($sel_id, $title, $path = ''): string |
||||
196 | { |
||||
197 | $sql = 'SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . (int)$sel_id; |
||||
198 | // $result = $this->db->query('SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $this->db->escape($sel_id) . "'"); |
||||
199 | |||||
200 | $categories = Utility::getMyItemIds('adslight_view'); |
||||
201 | if (\is_array($categories) && $categories !== []) { |
||||
202 | // $result .= ' AND cid IN (' . implode(',', $categories) . ') '; |
||||
203 | $sql .= ' AND cid IN (' . \implode(',', $categories) . ') '; |
||||
204 | } |
||||
205 | |||||
206 | $result = $this->db->query($sql); |
||||
207 | if (!$this->db->isResultSet($result)) { |
||||
208 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), E_USER_ERROR); |
||||
209 | } |
||||
210 | |||||
211 | if (0 === $this->db->getRowsNum($result)) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
212 | return $path; |
||||
213 | } |
||||
214 | [$parentid, $name] = $this->db->fetchRow($result); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
215 | \MyTextSanitizer::getInstance(); |
||||
216 | $name = \htmlspecialchars($name, \ENT_QUOTES | \ENT_HTML5); |
||||
217 | $path = '/' . $name . $path; |
||||
218 | if (0 === $parentid) { |
||||
219 | return $path; |
||||
220 | } |
||||
221 | |||||
222 | return $this->getPathFromId($parentid, $title, $path); |
||||
223 | } |
||||
224 | |||||
225 | /** |
||||
226 | * @param $title |
||||
227 | * @param string $order |
||||
228 | * @param int $preset_id |
||||
229 | * @param int $none |
||||
230 | * @param string $sel_name |
||||
231 | * @param string $onchange |
||||
232 | */ |
||||
233 | public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = ''): void |
||||
234 | { |
||||
235 | if ('' === $sel_name) { |
||||
236 | $sel_name = $this->id; |
||||
237 | } |
||||
238 | $myts = \MyTextSanitizer::getInstance(); |
||||
239 | echo '<select name="' . $sel_name . '"'; |
||||
240 | if ('' !== $onchange) { |
||||
241 | echo ' onchange="' . $onchange . '"'; |
||||
242 | } |
||||
243 | echo '>'; |
||||
244 | |||||
245 | $sql = 'SELECT SQL_CACHE cid, title FROM ' . $this->table . ' WHERE pid=0'; |
||||
246 | $categories = Utility::getMyItemIds('adslight_submit'); |
||||
247 | |||||
248 | if (\is_array($categories) && $categories !== []) { |
||||
249 | $sql .= ' AND cid IN (' . \implode(',', $categories) . ') '; |
||||
250 | } |
||||
251 | |||||
252 | if ('' !== $order) { |
||||
253 | $sql .= " ORDER BY {$order}"; |
||||
254 | } |
||||
255 | |||||
256 | $result = $this->db->query($sql); |
||||
257 | if (!$this->db->isResultSet($result)) { |
||||
258 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), E_USER_ERROR); |
||||
259 | } |
||||
260 | if (0 !== $none) { |
||||
261 | echo '<option value="0">----</option>'; |
||||
262 | } |
||||
263 | while (false !== [$catid, $name] = $this->db->fetchRow($result)) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
264 | $sel = ''; |
||||
265 | if ($catid === $preset_id) { |
||||
266 | $sel = ' selected'; |
||||
267 | } |
||||
268 | echo "<option value=\"{$catid}\"{$sel}>{$name}</option>"; |
||||
269 | $sel = ''; |
||||
270 | $arr = $this->getChildTreeArray($catid, $order); |
||||
271 | foreach ($arr as $option) { |
||||
272 | $option['prefix'] = \str_replace('.', '--', $option['prefix']); |
||||
273 | $catpath = $option['prefix'] . ' ' . $myts->displayTarea($option[$title]); |
||||
274 | if ($option['cid'] === $preset_id) { |
||||
275 | $sel = ' selected'; |
||||
276 | } |
||||
277 | echo "<option value=\"{$option['cid']}\"{$sel}>{$catpath}</option>"; |
||||
278 | $sel = ''; |
||||
279 | } |
||||
280 | } |
||||
281 | echo '</select>'; |
||||
282 | } |
||||
283 | |||||
284 | /** |
||||
285 | * @param $sel_id |
||||
286 | * @param $title |
||||
287 | * @param $funcURL |
||||
288 | * @param string $path |
||||
289 | * @return string |
||||
290 | */ |
||||
291 | public function getNicePathFromId($sel_id, $title, $funcURL, $path = ''): string |
||||
292 | { |
||||
293 | $sql = 'SELECT SQL_CACHE ' . $this->pid . ", {$title} FROM " . $this->table . ' WHERE ' . $this->id . '=' . (int)$sel_id; |
||||
294 | $result = $this->db->query($sql); |
||||
295 | if (!$this->db->isResultSet($result)) { |
||||
296 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), E_USER_ERROR); |
||||
297 | } |
||||
298 | if (0 === $this->db->getRowsNum($result)) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
299 | return $path; |
||||
300 | } |
||||
301 | [$parentid, $name] = $this->db->fetchRow($result); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
302 | \MyTextSanitizer::getInstance(); |
||||
303 | $name = \htmlspecialchars($name, \ENT_QUOTES | \ENT_HTML5); |
||||
304 | |||||
305 | $arrow = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="»" >'; |
||||
306 | |||||
307 | $path = " {$arrow} <a title=\"" . \_ADSLIGHT_ANNONCES . " {$name}\" href=\"{$funcURL}" . $this->id . '=' . (int)$sel_id . "\">{$name}</a>{$path}"; |
||||
308 | |||||
309 | if (0 === $parentid) { |
||||
310 | return $path; |
||||
311 | } |
||||
312 | |||||
313 | return $this->getNicePathFromId($parentid, $title, $funcURL, $path); |
||||
314 | } |
||||
315 | |||||
316 | /** |
||||
317 | * @param $sel_id |
||||
318 | * @param string $path |
||||
319 | * @return string |
||||
320 | */ |
||||
321 | public function getIdPathFromId($sel_id, $path = ''): string |
||||
322 | { |
||||
323 | $sel_id = (int)$sel_id; |
||||
324 | $sql = 'SELECT SQL_CACHE ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $sel_id; |
||||
325 | $result = $this->db->query($sql); |
||||
326 | if (!$this->db->isResultSet($result)) { |
||||
327 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), E_USER_ERROR); |
||||
328 | } |
||||
329 | if (0 === $this->db->getRowsNum($result)) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
330 | return $path; |
||||
331 | } |
||||
332 | [$parentid] = $this->db->fetchRow($result); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
333 | $path = "/{$sel_id}{$path}"; |
||||
334 | if (0 === $parentid) { |
||||
335 | return $path; |
||||
336 | } |
||||
337 | |||||
338 | return $this->getIdPathFromId($parentid, $path); |
||||
339 | } |
||||
340 | |||||
341 | /** |
||||
342 | * @param int $sel_id |
||||
343 | * @param string $order |
||||
344 | * @param array $parray |
||||
345 | */ |
||||
346 | public function getAllChild($sel_id = 0, $order = '', $parray = []): array |
||||
347 | { |
||||
348 | $sql = 'SELECT SQL_CACHE * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id; |
||||
349 | |||||
350 | $categories = Utility::getMyItemIds('adslight_view'); |
||||
351 | if (\is_array($categories) && $categories !== []) { |
||||
352 | $sql .= ' AND ' . $this->pid . ' IN (' . \implode(',', $categories) . ') '; |
||||
353 | } |
||||
354 | |||||
355 | if ('' !== $order) { |
||||
356 | $sql .= " ORDER BY {$order}"; |
||||
357 | } |
||||
358 | |||||
359 | $result = $this->db->query($sql); |
||||
360 | if (!$this->db->isResultSet($result)) { |
||||
361 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), \E_USER_ERROR); |
||||
362 | } |
||||
363 | $count = $this->db->getRowsNum($result); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
364 | if (0 === $count) { |
||||
365 | return $parray; |
||||
366 | } |
||||
367 | while (false !== ($row = $this->db->fetchArray($result))) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
368 | $parray[] = $row; |
||||
369 | $parray = $this->getAllChild($row[$this->id], $order, $parray); |
||||
370 | } |
||||
371 | |||||
372 | return $parray; |
||||
373 | } |
||||
374 | |||||
375 | /** |
||||
376 | * @param int $sel_id |
||||
377 | * @param string $order |
||||
378 | * @param array $parray |
||||
379 | * @param string $r_prefix |
||||
380 | */ |
||||
381 | public function getChildTreeArray($sel_id = 0, $order = '', $parray = [], $r_prefix = ''): array |
||||
382 | { |
||||
383 | $sql = 'SELECT SQL_CACHE * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id; |
||||
384 | |||||
385 | $categories = Utility::getMyItemIds('adslight_view'); |
||||
386 | if (\is_array($categories) && $categories !== []) { |
||||
387 | $sql .= ' AND cid IN (' . \implode(',', $categories) . ') '; |
||||
388 | } |
||||
389 | |||||
390 | if ('' !== $order) { |
||||
391 | $sql .= " ORDER BY {$order}"; |
||||
392 | } |
||||
393 | $result = $this->db->query($sql); |
||||
394 | if (!$this->db->isResultSet($result)) { |
||||
395 | \trigger_error("Query Failed! SQL: $sql- Error: " . $this->db->error(), \E_USER_ERROR); |
||||
396 | } |
||||
397 | $count = $this->db->getRowsNum($result); |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
398 | if (0 === $count) { |
||||
399 | return $parray; |
||||
400 | } |
||||
401 | while (false !== ($row = $this->db->fetchArray($result))) { |
||||
0 ignored issues
–
show
It seems like
$result can also be of type boolean ; 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
![]() |
|||||
402 | $row['prefix'] = $r_prefix . '.'; |
||||
403 | $parray[] = $row; |
||||
404 | $parray = $this->getChildTreeArray($row[$this->id], $order, $parray, $row['prefix']); |
||||
405 | } |
||||
406 | |||||
407 | return $parray; |
||||
408 | } |
||||
409 | |||||
410 | /** |
||||
411 | * @param $title |
||||
412 | * @param string $order |
||||
413 | * @param int $preset_id |
||||
414 | * @param int $none |
||||
415 | * @param string $sel_name |
||||
416 | * @param string $onchange |
||||
417 | */ |
||||
418 | public function makeAdSelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = ''): void |
||||
419 | { |
||||
420 | global $myts, $xoopsDB; |
||||
421 | $helper = Helper::getInstance(); |
||||
422 | $pathIcon16 = Admin::iconUrl('', '16'); |
||||
423 | // require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php'; |
||||
424 | |||||
425 | if ('' === $sel_name) { |
||||
426 | $sel_name = $this->id; |
||||
427 | } |
||||
428 | |||||
429 | $sql = 'SELECT ' . $this->id . ', ' . $title . ', cat_order FROM ' . $this->table . ' WHERE ' . $this->pid . '=0'; |
||||
430 | if ('' !== $order) { |
||||
431 | $sql .= " ORDER BY {$order}"; |
||||
432 | } |
||||
433 | $result = $xoopsDB->query($sql); |
||||
434 | if (!$xoopsDB->isResultSet($result)) { |
||||
435 | \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR); |
||||
436 | } |
||||
437 | while (false !== [$catid, $name, $cat_order] = $xoopsDB->fetchRow($result)) { |
||||
438 | echo '<table class="width100 bnone outer"><tr> |
||||
439 | <th class="left">'; |
||||
440 | if ('cat_order' === $helper->getConfig('adslight_csortorder')) { |
||||
441 | echo "({$cat_order})"; |
||||
442 | } |
||||
443 | echo " {$name} </th> |
||||
444 | <th class=\"center width10\"><a href=\"category.php?op=AdsNewCat&cid={$catid}\"><img src=\"{$pathIcon16}/add.png\" border=\"0\" width=\"18\" height=\"18\" alt=\"" . \_AM_ADSLIGHT_ADDSUBCAT . '" title="' . \_AM_ADSLIGHT_ADDSUBCAT . "\"></a></th> |
||||
445 | <th class=\"center width10\"><a href=\"category.php?op=AdsModCat&cid={$catid}\"><img src=\"{$pathIcon16}/edit.png\" border=\"0\" width=\"18\" height=\"18\" alt=\"" . \_AM_ADSLIGHT_MODIFSUBCAT . '" title="' . \_AM_ADSLIGHT_MODIFSUBCAT . "\"></a></th> |
||||
446 | <th class=\"center width10\"><a href=\"category.php?op=AdsDelCat&cid={$catid}\"><img src=\"{$pathIcon16}/delete.png\" border=\"0\" width=\"18\" height=\"18\" alt=\"" . \_AM_ADSLIGHT_DELSUBCAT . '" title="' . \_AM_ADSLIGHT_DELSUBCAT . '"></a></th> |
||||
447 | </tr>'; |
||||
448 | |||||
449 | $arr = $this->getChildTreeMapArray($catid, $order); |
||||
450 | $class = 'odd'; |
||||
451 | foreach ($arr as $option) { |
||||
452 | echo "<tr class=\"{$class}\"><td>"; |
||||
453 | |||||
454 | $option['prefix'] = \str_replace('.', ' - ', $option['prefix']); |
||||
455 | $catpath = $option['prefix'] . ' ' . \htmlspecialchars($option[$title], \ENT_QUOTES | \ENT_HTML5); |
||||
456 | $cat_orderS = $option['cat_order']; |
||||
457 | if ('cat_order' === $helper->getConfig('adslight_csortorder')) { |
||||
458 | echo "({$cat_orderS})"; |
||||
459 | } |
||||
460 | echo $catpath . '</a></td> |
||||
461 | <td align="center"><a href="category.php?op=AdsNewCat&cid=' . $option[$this->id] . '"><img src="' . $pathIcon16 . '/add.png' . '" border=0 width=18 height=18 alt="' . \_AM_ADSLIGHT_ADDSUBCAT . '"title="' . \_AM_ADSLIGHT_ADDSUBCAT . '"></a></td> |
||||
462 | <td align="center"><a href="category.php?op=AdsModCat&cid=' . $option[$this->id] . '"><img src="' . $pathIcon16 . '/edit.png' . '" border=0 width=18 height=18 alt="' . \_AM_ADSLIGHT_MODIFSUBCAT . '" title ="' . \_AM_ADSLIGHT_MODIFSUBCAT . '"></a></td> |
||||
463 | <td align="center"><a href="category.php?op=AdsDelCat&cid=' . $option[$this->id] . '"><img src="' . $pathIcon16 . '/delete.png' . '" border=0 width=18 height=18 alt="' . \_AM_ADSLIGHT_DELSUBCAT . '" title="' . \_AM_ADSLIGHT_DELSUBCAT . '"></a></td>'; |
||||
464 | |||||
465 | $class = 'even' === $class ? 'odd' : 'even'; |
||||
466 | } |
||||
467 | echo '</td></tr></table><br>'; |
||||
468 | } |
||||
469 | } |
||||
470 | |||||
471 | /** |
||||
472 | * @param int $sel_id |
||||
473 | * @param string $order |
||||
474 | * @param array $parray |
||||
475 | * @param string $r_prefix |
||||
476 | */ |
||||
477 | public function getChildTreeMapArray($sel_id = 0, $order = '', $parray = [], $r_prefix = ''): array |
||||
478 | { |
||||
479 | global $xoopsDB; |
||||
480 | $sql = 'SELECT SQL_CACHE * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $sel_id . ' '; |
||||
481 | |||||
482 | $categories = Utility::getMyItemIds('adslight_view'); |
||||
483 | if (\is_array($categories) && $categories !== []) { |
||||
484 | $sql .= ' AND ' . $this->pid . ' IN (' . \implode(',', $categories) . ') '; |
||||
485 | } |
||||
486 | |||||
487 | if ('' !== $order) { |
||||
488 | $sql .= " ORDER BY {$order}"; |
||||
489 | } |
||||
490 | $result = $xoopsDB->query($sql); |
||||
491 | if (!$xoopsDB->isResultSet($result)) { |
||||
492 | \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR); |
||||
493 | } |
||||
494 | $count = $xoopsDB->getRowsNum($result); |
||||
495 | if (0 === $count) { |
||||
496 | return $parray; |
||||
497 | } |
||||
498 | while (false !== ($row = $xoopsDB->fetchArray($result))) { |
||||
499 | $row['prefix'] = $r_prefix . '.'; |
||||
500 | $parray[] = $row; |
||||
501 | $parray = $this->getChildTreeMapArray($row[$this->id], $order, $parray, $row['prefix']); |
||||
502 | } |
||||
503 | |||||
504 | return $parray; |
||||
505 | } |
||||
506 | |||||
507 | public function getCategoryList(): array |
||||
508 | { |
||||
509 | global $xoopsDB; |
||||
510 | $sql = 'SELECT SQL_CACHE cid, pid, title FROM ' . $this->table; |
||||
511 | $result = $xoopsDB->query($sql); |
||||
512 | if (!$xoopsDB->isResultSet($result)) { |
||||
513 | \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR); |
||||
514 | } |
||||
515 | |||||
516 | $ret = []; |
||||
517 | \MyTextSanitizer::getInstance(); |
||||
518 | while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
||||
519 | $ret[$myrow['cid']] = [ |
||||
520 | 'title' => \htmlspecialchars($myrow['title'], \ENT_QUOTES | \ENT_HTML5), |
||||
521 | 'pid' => $myrow['pid'], |
||||
522 | ]; |
||||
523 | } |
||||
524 | |||||
525 | return $ret; |
||||
526 | } |
||||
527 | } |
||||
528 |