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 | /* |
||
4 | * You may not change or alter any portion of this comment or credits |
||
5 | * of supporting developers from this source code or any supporting source code |
||
6 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
7 | * |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
11 | */ |
||
12 | |||
13 | /** |
||
14 | * @copyright XOOPS Project (https://xoops.org) |
||
15 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
16 | * @author XOOPS Development Team |
||
17 | * @author Pascal Le Boustouller: original author ([email protected]) |
||
18 | * @author Luc Bizet (www.frxoops.org) |
||
19 | * @author jlm69 (www.jlmzone.com) |
||
20 | * @author mamba (www.xoops.org) |
||
21 | */ |
||
22 | |||
23 | use Xmf\Request; |
||
24 | use XoopsModules\Adslight\{ |
||
25 | Helper, |
||
26 | Utility |
||
27 | }; |
||
28 | |||
29 | /** @var Helper $helper */ |
||
30 | $moduleDirName = \basename(__DIR__); |
||
31 | //@todo replace the following code - use Filters |
||
32 | foreach ($_REQUEST as $key => $val) { |
||
33 | $val = preg_replace('/[^_A-Za-z0-9-\.&=]/i', '', $val); |
||
34 | $_REQUEST[$key] = $val; |
||
35 | } |
||
36 | |||
37 | $xoopsOption['pagetype'] = 'search'; |
||
38 | |||
39 | require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
||
40 | |||
41 | global $xoopsModule, $xoopsDB, $xoopsConfig, $xoTheme; |
||
42 | |||
43 | $helper = Helper::getInstance(); |
||
44 | $helper->loadLanguage('admin'); |
||
45 | |||
46 | $xmid = $xoopsModule->getVar('mid'); |
||
47 | /** @var \XoopsConfigHandler $configHandler */ |
||
48 | $configHandler = xoops_getHandler('config'); |
||
49 | $xoopsConfigSearch = $configHandler->getConfigsByCat(XOOPS_CONF_SEARCH); |
||
50 | if (1 !== (int)$xoopsConfigSearch['enable_search']) { |
||
51 | // header("Location: '.XOOPS_URL.'modules/adslight/index.php"); |
||
52 | $helper->redirect('index.php', 1); |
||
53 | } |
||
54 | |||
55 | $action = Request::getString('action', 'search'); |
||
56 | $query = Request::getString('query', ''); |
||
57 | $andor = Request::getString('andor', 'AND'); |
||
58 | $mid = Request::getInt('mid', 0); |
||
59 | $uid = Request::getInt('uid', 0); |
||
60 | $start = Request::getInt('start', 0); |
||
61 | |||
62 | $queries = []; |
||
63 | |||
64 | if ('results' === $action) { |
||
65 | if ('' === $query) { |
||
66 | $helper->redirect('search.php', 1, _SR_PLZENTER); |
||
67 | } |
||
68 | } elseif ('showall' === $action) { |
||
69 | if ('' === $query || empty($mid)) { |
||
70 | $helper->redirect('search.php', 1, _SR_PLZENTER); |
||
71 | } |
||
72 | } elseif ('showallbyuser' === $action) { |
||
73 | if (empty($mid) || empty($uid)) { |
||
74 | $helper->redirect('search.php', 1, _SR_PLZENTER); |
||
75 | } |
||
76 | } |
||
77 | |||
78 | $groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
79 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
80 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
81 | $available_modules = $grouppermHandler->getItemIds('module_read', $groups); |
||
82 | |||
83 | if ('search' === $action) { |
||
84 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
85 | require_once __DIR__ . '/include/searchform.php'; |
||
86 | $search_form->display(); |
||
87 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
88 | exit(); |
||
89 | } |
||
90 | |||
91 | if ('OR' !== $andor && 'exact' !== $andor && 'AND' !== $andor) { |
||
92 | $andor = 'AND'; |
||
93 | } |
||
94 | |||
95 | $myts = \MyTextSanitizer::getInstance(); |
||
96 | if ('showallbyuser' !== $action) { |
||
97 | if ('exact' !== $andor) { |
||
98 | $ignored_queries = []; // holds keywords that are shorter than allowed mininum length |
||
99 | $temp_queries = preg_split('/[\s,]+/', $query); |
||
100 | foreach ($temp_queries as $q) { |
||
101 | $q = trim($q); |
||
102 | if (mb_strlen($q) >= $xoopsConfigSearch['keyword_min']) { |
||
103 | $queries[] = $GLOBALS['xoopsDB']->escape($q); |
||
104 | } else { |
||
105 | $ignored_queries[] = $GLOBALS['xoopsDB']->escape($q); |
||
106 | } |
||
107 | } |
||
108 | if (0 === count($queries)) { |
||
109 | $helper->redirect('search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); |
||
110 | } |
||
111 | } else { |
||
112 | $query = trim($query); |
||
113 | if (mb_strlen($query) < $xoopsConfigSearch['keyword_min']) { |
||
114 | $helper->redirect('search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); |
||
115 | } |
||
116 | $queries = [$GLOBALS['xoopsDB']->escape($query)]; |
||
117 | } |
||
118 | } |
||
119 | switch ($action) { |
||
120 | case 'results': |
||
121 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
122 | $moduleHandler = xoops_getHandler('module'); |
||
123 | $criteria = new \CriteriaCompo(new \Criteria('hassearch', '1')); |
||
124 | $criteria->add(new \Criteria('isactive', '1')); |
||
125 | $criteria->add(new \Criteria('mid', '(' . implode(',', $available_modules) . ')', 'IN')); |
||
126 | $modules = $moduleHandler->getObjects($criteria, true); |
||
127 | $mids = Request::getArray('mids', []); |
||
128 | if (empty($mids) || !is_array($mids)) { |
||
129 | unset($mids); |
||
130 | $mids = array_keys($xmid); |
||
131 | } |
||
132 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
133 | |||
134 | // for xoops 2.2.x versions |
||
135 | // xoops_loadLanguage('main', $moduleDirName); |
||
136 | // end |
||
137 | |||
138 | echo '<h3>' . _ADSLIGHT_SEARCHRESULTS . "</h3>\n"; |
||
139 | echo _SR_KEYWORDS . ':'; |
||
140 | if ('exact' !== $andor) { |
||
141 | foreach ($queries as $q) { |
||
142 | echo ' <strong>' . htmlspecialchars(stripslashes($q), ENT_QUOTES | ENT_HTML5) . '</strong>'; |
||
143 | } |
||
144 | if (!empty($ignored_queries)) { |
||
145 | echo '<br>'; |
||
146 | printf(_SR_IGNOREDWORDS, $xoopsConfigSearch['keyword_min']); |
||
147 | foreach ($ignored_queries as $q) { |
||
148 | echo ' <strong>' . htmlspecialchars(stripslashes($q), ENT_QUOTES | ENT_HTML5) . '</strong>'; |
||
149 | } |
||
150 | } |
||
151 | } else { |
||
152 | echo ' "<strong>' . htmlspecialchars(stripslashes($queries[0]), ENT_QUOTES | ENT_HTML5) . '</strong>"'; |
||
153 | } |
||
154 | echo '<br>'; |
||
155 | foreach ($mids as $mid) { |
||
156 | $mid = (int)$mid; |
||
157 | if (\in_array($mid, $available_modules, true)) { |
||
158 | $module = $modules[$mid]; |
||
159 | $results = $module->search($queries, $andor, 5, 0); |
||
160 | $count = 0; |
||
161 | if (is_array($results)) { |
||
162 | $count = count($results); |
||
163 | } |
||
164 | if (!is_array($results) || 0 === $count) { |
||
165 | echo '<p>' . _SR_NOMATCH . '</p>'; |
||
166 | } else { |
||
167 | for ($i = 0; $i < $count; ++$i) { |
||
168 | // echo '<style type="text/css" media="all">@import url(' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css);</style>'; |
||
169 | echo '<style type="text/css" media="all">@import url(' . $helper->url('assets/css/adslight.css') . ');</style>'; |
||
170 | echo '<table width="100%" class="outer"><tr>'; |
||
171 | echo '<td width="30%">'; |
||
172 | echo '<strong>' . htmlspecialchars($results[$i]['type'], ENT_QUOTES | ENT_HTML5) . '</strong><br>'; |
||
173 | if (isset($results[$i]['photo']) |
||
174 | && '' !== $results[$i]['photo']) { |
||
175 | echo "<a href='" . $results[$i]['link'] . "'><img class='thumb' src='" . $results[$i]['photo'] . "' alt='' width='100' ></a></td> "; |
||
176 | } else { |
||
177 | echo "<a href='" . $results[$i]['link'] . "'><img class='thumb' src='" . $results[$i]['nophoto'] . "' alt='' width='100' ></a></td> "; |
||
178 | } |
||
179 | if (!preg_match('/^http[s]*:\/\//i', $results[$i]['link'])) { |
||
180 | $results[$i]['link'] = '' . $results[$i]['link']; |
||
181 | } |
||
182 | echo '<td width="50%">'; |
||
183 | |||
184 | echo "<strong><a href='" . $results[$i]['link'] . "'>" . htmlspecialchars($results[$i]['title'], ENT_QUOTES | ENT_HTML5) . '</a></strong><br><br>'; |
||
185 | |||
186 | if (!XOOPS_USE_MULTIBYTES) { |
||
187 | if (mb_strlen($results[$i]['desctext']) >= 14) { |
||
188 | $results[$i]['desctext'] = $myts->displayTarea(mb_substr($results[$i]['desctext'], 0, 90), 1, 1, 1, 1, 1); |
||
189 | } |
||
190 | } |
||
191 | |||
192 | echo $myts->displayTarea($results[$i]['desctext'], 1, 1, 1, 1, 1); |
||
193 | $sql = 'SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' WHERE id_price=' . (int)$results[$i]['typeprice']; |
||
194 | $result8 = $xoopsDB->query($sql); |
||
195 | if (!$xoopsDB->isResultSet($result8)) { |
||
196 | \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR); |
||
197 | } |
||
198 | [$nom_price] = $xoopsDB->fetchRow($result8); |
||
199 | // $a_item['typeprice'] = $nom_price; |
||
200 | |||
201 | $currencyCode = $helper->getConfig('adslight_currency_code'); |
||
202 | $currencySymbol = $helper->getConfig('adslight_currency_symbol'); |
||
203 | $currencyPosition = $helper->getConfig('currency_position'); |
||
204 | $formattedCurrencyUtilityTemp = Utility::formatCurrencyTemp((float)$results[$i]['price'], $currencyCode, $currencySymbol, $currencyPosition); |
||
205 | |||
206 | $priceHtml = $formattedCurrencyUtilityTemp . ' - ' . $nom_price; |
||
207 | |||
208 | echo '</td><td width="20%">'; |
||
209 | echo $priceHtml . '</a>'; |
||
210 | |||
211 | echo '</td></tr><tr><td>'; |
||
212 | echo '<small>'; |
||
213 | $results[$i]['uid'] = @(int)$results[$i]['uid']; |
||
214 | if (!empty($results[$i]['uid'])) { |
||
215 | $uname = \XoopsUser::getUnameFromId($results[$i]['uid']); |
||
216 | echo ' ' . _ADSLIGHT_FROM . "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $results[$i]['uid'] . "'>" . $uname . "</a>\n"; |
||
217 | } |
||
218 | echo !empty($results[$i]['time']) ? ' (' . formatTimestamp((int)$results[$i]['time']) . ')' : ''; |
||
219 | echo '</small>'; |
||
220 | echo '</td></tr></table><table>'; |
||
221 | } |
||
222 | if ($count >= 5) { |
||
223 | $search_url = XOOPS_URL . '/modules/adslight/search.php?query=' . urlencode(stripslashes(implode(' ', $queries))); |
||
224 | $search_url .= "&mid={$mid}&action=showall&andor={$andor}"; |
||
225 | echo '<br><a href="' . htmlspecialchars($search_url, ENT_QUOTES | ENT_HTML5) . '">' . _SR_SHOWALLR . '</a>'; |
||
226 | } |
||
227 | echo '<table>'; |
||
228 | } |
||
229 | } |
||
230 | unset($results, $module); |
||
231 | } |
||
232 | require_once __DIR__ . '/include/searchform.php'; |
||
233 | $search_form->display(); |
||
234 | break; |
||
235 | case 'showall': |
||
236 | case 'showallbyuser': |
||
237 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
238 | |||
239 | $GLOBALS['xoopsTpl']->assign('imgscss', $helper->url('assets/css/adslight.css')); |
||
240 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
241 | $moduleHandler = xoops_getHandler('module'); |
||
242 | $module = $moduleHandler->get($mid); |
||
243 | $results = $module->search($queries, $andor, 20, $start, $uid); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
244 | $count = 0; |
||
245 | if (is_array($results)) { |
||
246 | $count = count($results); |
||
247 | } |
||
248 | if ($count > 0) { |
||
249 | $next_results = $module->search($queries, $andor, 1, $start + 20, $uid); |
||
250 | $count = 0; |
||
251 | if (is_array($next_results)) { |
||
252 | $count = count($next_results); |
||
253 | } |
||
254 | $has_next = false; |
||
255 | if (is_array($next_results) && 1 === $next_count) { |
||
256 | $has_next = true; |
||
257 | } |
||
258 | echo '<h4>' . _ADSLIGHT_SEARCHRESULTS . "</h4>\n"; |
||
259 | if ('showall' === $action) { |
||
260 | echo _SR_KEYWORDS . ':'; |
||
261 | if ('exact' !== $andor) { |
||
262 | foreach ($queries as $q) { |
||
263 | echo ' <strong>' . htmlspecialchars(stripslashes($q), ENT_QUOTES | ENT_HTML5) . '</strong>'; |
||
264 | } |
||
265 | } else { |
||
266 | echo ' "<strong>' . htmlspecialchars(stripslashes($queries[0]), ENT_QUOTES | ENT_HTML5) . '</strong>"'; |
||
267 | } |
||
268 | echo '<br><br>'; |
||
269 | } |
||
270 | // printf(_SR_FOUND,$count); |
||
271 | // echo "<br>"; |
||
272 | printf(_SR_SHOWING, $start + 1, $start + $count); |
||
273 | for ($i = 0; $i < $count; ++$i) { |
||
274 | echo '<table width="100%" class="outer"><tr>'; |
||
275 | echo '<td width="30%">'; |
||
276 | echo '<strong>' . htmlspecialchars($results[$i]['type'], ENT_QUOTES | ENT_HTML5) . '</strong><br>'; |
||
277 | if (isset($results[$i]['photo']) |
||
278 | && '' !== $results[$i]['photo']) { |
||
279 | echo "<a href='" . $results[$i]['link'] . "'><img class='thumb' src='" . $results[$i]['sphoto'] . "' alt='' width='100' ></a></td> "; |
||
280 | } else { |
||
281 | echo "<a href='" . $results[$i]['link'] . "'><img class='thumb' src='" . $results[$i]['nophoto'] . "' alt='' width='100' ></a></td> "; |
||
282 | } |
||
283 | if (!preg_match('/^http[s]*:\/\//i', $results[$i]['link'])) { |
||
284 | $results[$i]['link'] = '' . $results[$i]['link']; |
||
285 | } |
||
286 | echo '<td width="50%">'; |
||
287 | |||
288 | echo "<strong><a href='" . $results[$i]['link'] . "'>" . htmlspecialchars($results[$i]['title'], ENT_QUOTES | ENT_HTML5) . '</a></strong><br><br>'; |
||
289 | |||
290 | if (!XOOPS_USE_MULTIBYTES) { |
||
291 | if (mb_strlen($results[$i]['desctext']) >= 14) { |
||
292 | $results[$i]['desctext'] = mb_substr($results[$i]['desctext'], 0, 90) . '...'; |
||
293 | } |
||
294 | } |
||
295 | |||
296 | echo htmlspecialchars($results[$i]['desctext'], ENT_QUOTES | ENT_HTML5); |
||
297 | |||
298 | echo '</td><td width="20%">'; |
||
299 | echo '' . $helper->getConfig('adslight_currency_symbol') . ' |
||
300 | ' . htmlspecialchars($results[$i]['price'], ENT_QUOTES | ENT_HTML5) . '</a> ' . htmlspecialchars($results[$i]['typeprice'], ENT_QUOTES | ENT_HTML5) . '</a>'; |
||
301 | |||
302 | echo '</td></tr><tr><td>'; |
||
303 | echo '<small>'; |
||
304 | $results[$i]['uid'] = @(int)$results[$i]['uid']; |
||
305 | if (!empty($results[$i]['uid'])) { |
||
306 | $uname = \XoopsUser::getUnameFromId($results[$i]['uid']); |
||
307 | echo ' ' . _ADSLIGHT_FROM . "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $results[$i]['uid'] . "'>" . $uname . '</a><br>'; |
||
308 | } |
||
309 | echo !empty($results[$i]['time']) ? ' (' . formatTimestamp((int)$results[$i]['time']) . ')' : ''; |
||
310 | echo '</small>'; |
||
311 | echo '</td></tr></table><table>'; |
||
312 | } |
||
313 | |||
314 | echo ' |
||
315 | <table> |
||
316 | <tr> |
||
317 | '; |
||
318 | $search_url = XOOPS_URL . '/modules/adslight/search.php?query=' . urlencode(stripslashes(implode(' ', $queries))); |
||
319 | $search_url .= "&mid={$mid}&action={$action}&andor={$andor}"; |
||
320 | if ('showallbyuser' === $action) { |
||
321 | $search_url .= "&uid={$uid}"; |
||
322 | } |
||
323 | if ($start > 0) { |
||
324 | $prev = $start - 20; |
||
325 | echo '<td align="left"> |
||
326 | '; |
||
327 | $search_url_prev = $search_url . "&start={$prev}"; |
||
328 | echo '<a href="' . htmlspecialchars($search_url_prev, ENT_QUOTES | ENT_HTML5) . '">' . _SR_PREVIOUS . '</a></td> |
||
329 | '; |
||
330 | } |
||
331 | echo '<td> </td> |
||
332 | '; |
||
333 | if (false !== $has_next) { |
||
334 | $next = $start + 20; |
||
335 | $search_url_next = $search_url . "&start={$next}"; |
||
336 | echo '<td align="right"><a href="' . htmlspecialchars($search_url_next, ENT_QUOTES | ENT_HTML5) . '">' . _SR_NEXT . '</a></td> |
||
337 | '; |
||
338 | } |
||
339 | echo ' |
||
340 | </tr> |
||
341 | </table> |
||
342 | <p> |
||
343 | '; |
||
344 | } else { |
||
345 | echo '<p>' . _SR_NOMATCH . '</p>'; |
||
346 | } |
||
347 | require_once __DIR__ . '/include/searchform.php'; |
||
348 | $search_form->display(); |
||
349 | echo '</p> |
||
350 | '; |
||
351 | break; |
||
352 | } |
||
353 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
354 |