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.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | You may not change or alter any portion of this comment or credits |
||
4 | of supporting developers from this source code or any supporting source code |
||
5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | |||
7 | This program is distributed in the hope that it will be useful, |
||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * XOOPS global search |
||
14 | * |
||
15 | * @copyright XOOPS Project https://xoops.org/ |
||
16 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
17 | * @package core |
||
18 | * @since 2.0.0 |
||
19 | * @author Kazumi Ono (AKA onokazu) |
||
20 | * @author Taiwen Jiang <[email protected]> |
||
21 | * @author Edited by John Mordo (jlm69) |
||
22 | * @version $Id$ |
||
23 | */ |
||
24 | |||
25 | use Xoops\Core\Request; |
||
26 | use Xoops\Core\Kernel\Handlers\XoopsUser; |
||
27 | |||
28 | include dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
29 | include_once __DIR__ . '/header.php'; |
||
30 | include_once __DIR__ . '/include/common.php'; |
||
31 | $alumni = Alumni::getInstance(); |
||
32 | $search = Search::getInstance(); |
||
33 | if (!$search->getConfig('enable_search')) { |
||
34 | header('Location: ' . XOOPS_URL . '/index.php'); |
||
35 | exit(); |
||
36 | } |
||
37 | |||
38 | $xoops = Xoops::getInstance(); |
||
39 | |||
40 | $action = Request::getCmd('action', 'search'); |
||
41 | $query = Request::getString('query', ''); |
||
42 | $andor = Request::getWord('andor', 'AND'); |
||
43 | $mid = Request::getInt('mid', 0); |
||
44 | $uid = Request::getInt('uid', 0); |
||
45 | $start = Request::getInt('start', 0); |
||
46 | $limit = Request::getInt('start', 1000); |
||
47 | $by_cat = Request::getInt('by_cat'); |
||
48 | $mids = Request::getArray('mids', []); |
||
49 | $xmid = $xoops->module->getVar('mid'); |
||
50 | $queries = []; |
||
51 | |||
52 | if ('results' === $action) { |
||
53 | if ('' == $query && ('' == $by_cat)) { |
||
54 | $xoops->redirect('index.php', 1, _MD_SEARCH_PLZENTER); |
||
55 | } |
||
56 | } else { |
||
57 | if ('showall' === $action) { |
||
58 | if ('' == $query || empty($mid)) { |
||
59 | $xoops->redirect('index.php', 1, _MD_SEARCH_PLZENTER); |
||
60 | } |
||
61 | } else { |
||
62 | if ('showallbyuser' === $action) { |
||
63 | if (empty($mid) || empty($uid)) { |
||
64 | $xoops->redirect('index.php', 1, _MD_SEARCH_PLZENTER); |
||
65 | } |
||
66 | } |
||
67 | } |
||
68 | } |
||
69 | |||
70 | $gperm_handler = $xoops->getHandlerGroupPermission(); |
||
0 ignored issues
–
show
|
|||
71 | $available_modules = $gperm_handler->getItemIds('module_read', $xoops->getUserGroups()); |
||
72 | $available_plugins = \Xoops\Module\Plugin::getPlugins('search'); |
||
73 | |||
74 | if ('search' === $action) { |
||
75 | $xoops->header(); |
||
76 | /* @var $formHandler SearchSearchForm */ |
||
77 | $formHandler = $alumni->getForm(null, 'search'); |
||
78 | $form = $formHandler->alumni_getSearchFrom($andor, $queries, $mids, $mid, $by_cat); |
||
79 | $form->display(); |
||
80 | $xoops->footer(); |
||
81 | } |
||
82 | if ('OR' !== $andor && 'exact' !== $andor && 'AND' !== $andor) { |
||
83 | $andor = 'AND'; |
||
84 | } |
||
85 | |||
86 | $ignored_queries = []; // holds kewords that are shorter than allowed minmum length |
||
87 | $queries_pattern = []; |
||
88 | $myts = \Xoops\Core\Text\Sanitizer::getInstance(); |
||
89 | if ('showallbyuser' !== $action) { |
||
90 | if ('exact' !== $andor) { |
||
91 | $temp_queries = str_getcsv($query, ' ', '"'); |
||
92 | foreach ($temp_queries as $q) { |
||
93 | $q = trim($q); |
||
94 | if (mb_strlen($q) >= $search->getConfig('keyword_min')) { |
||
95 | $queries[] = $q; |
||
96 | $queries_pattern[] = '~(' . $q . ')~sUi'; |
||
97 | } else { |
||
98 | $ignored_queries[] = $q; |
||
0 ignored issues
–
show
$ignored_queries does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
99 | } |
||
100 | } |
||
101 | if (0 == count($queries) && ('' == $by_cat)) { |
||
102 | $xoops->redirect('index.php', 2, sprintf(XoopsLocale::EF_KEYWORDS_MUST_BE_GREATER_THAN, $search->getConfig('keyword_min'))); |
||
103 | } |
||
104 | } else { |
||
105 | $query = trim($query); |
||
106 | if (mb_strlen($query) < $search->getConfig('keyword_min')) { |
||
107 | $xoops->redirect('index.php', 2, sprintf(XoopsLocale::EF_KEYWORDS_MUST_BE_GREATER_THAN, $search->getConfig('keyword_min'))); |
||
108 | } |
||
109 | $queries = [$query]; |
||
110 | $queries_pattern[] = '~(' . $query . ')~sUi'; |
||
111 | } |
||
112 | } |
||
113 | |||
114 | switch ($action) { |
||
115 | case 'results': |
||
116 | $module_handler = $xoops->getHandlerModule(); |
||
117 | $criteria = new CriteriaCompo(); |
||
118 | $criteria->add(new Criteria('dirname', "('" . implode("','", array_keys($available_plugins)) . "')", 'IN')); |
||
119 | $modules = $module_handler->getObjectsArray($criteria, true); |
||
120 | if (empty($mids) || !is_array($mids)) { |
||
121 | unset($mids); |
||
122 | $mids = array_keys($modules); |
||
123 | } |
||
124 | $xoops->header('module:alumni/alumni_search.tpl'); |
||
125 | $nomatch = true; |
||
126 | $xoops->tpl()->assign('search', true); |
||
127 | $xoops->tpl()->assign('queries', $queries); |
||
128 | $xoops->tpl()->assign('ignored_words', sprintf(XoopsLocale::F_KEYWORDS_SHORTER_THAN_WILL_BE_IGNORED, $search->getConfig('keyword_min'))); |
||
129 | $xoops->tpl()->assign('ignored_queries', $ignored_queries); |
||
130 | |||
131 | $modules_result = []; |
||
132 | foreach ($mids as $mid) { |
||
133 | $mid = (int)$mid; |
||
134 | /* @var $module XoopsModule */ |
||
135 | $module = $modules[$xmid]; |
||
136 | /* @var $plugin SearchPluginInterface */ |
||
137 | $plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'search'); |
||
138 | $all_results = $plugin->search($queries, $andor, $limit, 0, null); |
||
139 | $count2 = count($all_results); |
||
140 | $results = $plugin->search($queries, $andor, 5, 0, null); |
||
141 | $count = count($results); |
||
142 | |||
143 | $mid = $module->getVar('mid'); |
||
144 | |||
145 | $xoops->tpl()->assign('sr_showing', ''); |
||
146 | if ($count > 0) { |
||
147 | $xoops->tpl()->assign('sr_showing', sprintf(XoopsLocale::F_SHOWING_RESULTS, $start + 1, $start + $count)); |
||
148 | $xoops->tpl()->assign('showing_of', AlumniLocale::OF . "$count2"); |
||
149 | } |
||
150 | $xoops->tpl()->assign('in_category', ''); |
||
151 | $xoops->tpl()->assign('cat_name', ''); |
||
152 | View Code Duplication | if (!empty($by_cat)) { |
|
153 | $cat_name = ''; |
||
154 | $alumni_categories_Handler = $xoops->getModuleHandler('category', 'alumni'); |
||
155 | $catObj = $alumni_categories_Handler->get($by_cat); |
||
156 | $cat_name = $catObj->getVar('title'); |
||
157 | $xoops->tpl()->assign('in_category', AlumniLocale::INCATEGORY); |
||
158 | $xoops->tpl()->assign('cat_name', "<b> : $cat_name</b>"); |
||
159 | } |
||
160 | |||
161 | $res = []; |
||
162 | if (is_array($results) && $count > 0) { |
||
163 | $nomatch = false; |
||
164 | $modules_result[$mid]['name'] = $module->getVar('name'); |
||
165 | if (XoopsLoad::fileExists($image = $xoops->path('modules/' . $module->getVar('dirname') . '/icons/logo_large.png'))) { |
||
166 | $modules_result[$mid]['image'] = $xoops->url($image); |
||
167 | } else { |
||
168 | $modules_result[$mid]['image'] = $xoops->url('images/icons/posticon2.gif'); |
||
169 | } |
||
170 | $res = []; |
||
171 | for ($i = 0; $i < $count; ++$i) { |
||
172 | if (!preg_match("/^http[s]*:\/\//i", $results[$i]['link'])) { |
||
173 | $res[$i]['link'] = $xoops->url('modules/' . $module->getVar('dirname') . '/' . $results[$i]['link']); |
||
174 | } else { |
||
175 | $res[$i]['link'] = $results[$i]['link']; |
||
176 | } |
||
177 | $res[$i]['title'] = $myts->htmlSpecialChars($results[$i]['title']); |
||
178 | $res[$i]['title_highligh'] = preg_replace($queries_pattern, "<span class='searchHighlight'>$1</span>", $myts->htmlSpecialChars($results[$i]['title'])); |
||
179 | if (!empty($results[$i]['uid'])) { |
||
180 | $res[$i]['uid'] = (int)$results[$i]['uid']; |
||
181 | $res[$i]['uname'] = XoopsUser::getUnameFromId($results[$i]['uid'], true); |
||
182 | } |
||
183 | $res[$i]['time'] = !empty($results[$i]['time']) ? XoopsLocale::formatTimestamp((int)$results[$i]['time']) : ''; |
||
184 | $res[$i]['content'] = empty($results[$i]['content']) ? '' : preg_replace($queries_pattern, "<span class='searchHighlight'>$1</span>", $results[$i]['content']); |
||
185 | } |
||
186 | if ($count >= 5) { |
||
187 | $search_url = XOOPS_URL . '/modules/alumni/search.php?query=' . urlencode(stripslashes(implode(' ', $queries))); |
||
188 | $search_url .= "&mid={$mid}&action=showall&andor={$andor}&by_cat=$by_cat"; |
||
189 | $modules_result[$mid]['search_url'] = htmlspecialchars($search_url); |
||
190 | } |
||
191 | } |
||
192 | if (count($res) > 0) { |
||
193 | $modules_result[$mid]['result'] = $res; |
||
194 | } |
||
195 | } |
||
196 | unset($results); |
||
197 | unset($module); |
||
198 | |||
199 | $xoops->tpl()->assign('modules', $modules_result); |
||
200 | |||
201 | /* @var $formHandler SearchSearchForm */ |
||
202 | $formHandler = $alumni->getForm(null, 'search'); |
||
203 | $form = $formHandler->alumni_getSearchFrom($andor, $queries, $mids, $mid, $by_cat); |
||
204 | $form->display(); |
||
205 | break; |
||
206 | |||
207 | case 'showall': |
||
208 | case 'showallbyuser': |
||
209 | $xoops->header('module:search/search.tpl'); |
||
210 | $xoops->tpl()->assign('search', true); |
||
211 | $xoops->tpl()->assign('queries', $queries); |
||
212 | $xoops->tpl()->assign('ignored_words', sprintf(_MA_ALUMNI_IGNOREDWORDS, $search->getConfig('keyword_min'))); |
||
213 | $xoops->tpl()->assign('ignored_queries', $ignored_queries); |
||
214 | |||
215 | $module_handler = $xoops->getHandlerModule(); |
||
216 | $module = $xoops->getModuleById($mid); |
||
217 | /* @var $plugin SearchPluginInterface */ |
||
218 | $plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'search'); |
||
219 | $results = $plugin->search($queries, $andor, 20, $start, $uid); |
||
220 | $results2 = $plugin->search($queries, $andor, '', $start, $uid); |
||
221 | |||
222 | $modules_result[$mid]['name'] = $module->getVar('name'); |
||
223 | $modules_result[$mid]['image'] = $xoops->url('modules/' . $module->getVar('dirname') . '/icons/logo_large.png'); |
||
224 | |||
225 | $count = count($results); |
||
226 | $count2 = count($results2); |
||
227 | |||
228 | $xoops->tpl()->assign('sr_showing', ''); |
||
229 | if (is_array($results) && $count > 0) { |
||
230 | $next_results = $plugin->search($queries, $andor, 1, $start + 20, $uid); |
||
231 | $next_count = count($next_results); |
||
232 | $has_next = false; |
||
233 | if (is_array($next_results) && 1 == $next_count) { |
||
234 | $has_next = true; |
||
235 | } |
||
236 | $xoops->tpl()->assign('sr_showing', sprintf(XoopsLocale::F_SHOWING_RESULTS, $start + 1, $start + $count)); |
||
237 | $xoops->tpl()->assign('showing_of', constant($main_lang . '_OF') . " $count2"); |
||
238 | |||
239 | View Code Duplication | if (!empty($by_cat)) { |
|
240 | $cat_name = ''; |
||
241 | $alumni_categories_Handler = $xoops->getModuleHandler('category', 'alumni'); |
||
242 | $catObj = $alumni_categories_Handler->get($by_cat); |
||
243 | $cat_name = $catObj->getVar('title'); |
||
244 | $xoops->tpl()->assign('in_category', AlumniLocale::INCATEGORY); |
||
245 | $xoops->tpl()->assign('cat_name', "<b> : $cat_name</b>"); |
||
246 | } |
||
247 | |||
248 | $res = []; |
||
249 | for ($i = 0; $i < $count; ++$i) { |
||
250 | if (isset($results[$i]['image']) && '' != $results[$i]['image']) { |
||
251 | $res[$i]['image'] = $xoops->url('modules/' . $module->getVar('dirname') . '/' . $results[$i]['image']); |
||
252 | } else { |
||
253 | $res[$i]['image'] = $xoops->url('images/icons/posticon2.gif'); |
||
254 | } |
||
255 | if (!preg_match("/^http[s]*:\/\//i", $results[$i]['link'])) { |
||
256 | $res[$i]['link'] = $xoops->url('modules/' . $module->getVar('dirname') . '/' . $results[$i]['link']); |
||
257 | } else { |
||
258 | $res[$i]['link'] = $results[$i]['link']; |
||
259 | } |
||
260 | $res[$i]['title'] = $myts->htmlSpecialChars($results[$i]['title']); |
||
261 | if (isset($queries_pattern)) { |
||
262 | $res[$i]['title_highligh'] = preg_replace($queries_pattern, "<span class='searchHighlight'>$1</span>", $myts->htmlSpecialChars($results[$i]['title'])); |
||
263 | } else { |
||
264 | $res[$i]['title_highligh'] = $myts->htmlSpecialChars($results[$i]['title']); |
||
265 | } |
||
266 | if (!empty($results[$i]['uid'])) { |
||
267 | $res[$i]['uid'] = @(int)$results[$i]['uid']; |
||
268 | $res[$i]['uname'] = XoopsUser::getUnameFromId($results[$i]['uid'], true); |
||
269 | } |
||
270 | $res[$i]['time'] = !empty($results[$i]['time']) ? ' (' . XoopsLocale::formatTimestamp((int)$results[$i]['time']) . ')' : ''; |
||
271 | $res[$i]['content'] = empty($results[$i]['content']) ? '' : preg_replace($queries_pattern, "<span class='searchHighlight'>$1</span>", $results[$i]['content']); |
||
272 | } |
||
273 | if (count($res) > 0) { |
||
274 | $modules_result[$mid]['result'] = $res; |
||
275 | } |
||
276 | |||
277 | $search_url = XOOPS_URL . '/modules/alumni/search.php?query=' . urlencode(stripslashes(implode(' ', $queries))); |
||
278 | $search_url .= "&mid={$mid}&action={$action}&andor={$andor}&by_cat=$by_cat"; |
||
279 | if ('showallbyuser' === $action) { |
||
280 | $search_url .= "&uid={$uid}"; |
||
281 | } |
||
282 | View Code Duplication | if ($start > 0) { |
|
283 | $prev = $start - 20; |
||
284 | $search_url_prev = $search_url . "&start={$prev}"; |
||
285 | $modules_result[$mid]['prev'] = htmlspecialchars($search_url_prev); |
||
286 | } |
||
287 | View Code Duplication | if (false != $has_next) { |
|
288 | $next = $start + 20; |
||
289 | $search_url_next = $search_url . "&start={$next}"; |
||
290 | $modules_result[$mid]['next'] = htmlspecialchars($search_url_next); |
||
291 | } |
||
292 | $xoops->tpl()->assign('modules', $modules_result); |
||
293 | } |
||
294 | |||
295 | /* @var $formHandler SearchSearchForm */ |
||
296 | $formHandler = $alumni->getForm(null, 'search'); |
||
297 | $form = $formHandler->alumni_getSearchFrom($andor, $queries, $mids, $mid, $by_cat); |
||
298 | $form->display(); |
||
299 | break; |
||
300 | } |
||
301 | $xoops->footer(); |
||
302 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.