Issues (212)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

search.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
//
3
// ------------------------------------------------------------------------ //
4
// This program is free software; you can redistribute it and/or modify     //
5
// it under the terms of the GNU General Public License as published by     //
6
// the Free Software Foundation; either version 2 of the License, or        //
7
// (at your option) any later version.                                      //
8
//                                                                          //
9
// You may not change or alter any portion of this comment or credits       //
10
// of supporting developers from this source code or any supporting         //
11
// source code which is considered copyrighted (c) material of the          //
12
// original comment or credit authors.                                      //
13
//                                                                          //
14
// This program is distributed in the hope that it will be useful,          //
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           //
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
17
// GNU General Public License for more details.                             //
18
//                                                                          //
19
// You should have received a copy of the GNU General Public License        //
20
// along with this program; if not, write to the Free Software              //
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
22
// ------------------------------------------------------------------------ //
23
// Author: phppp (D.J., [email protected])                                  //
24
// URL: https://xoops.org                         //
25
// Project: Article Project                                                 //
26
// ------------------------------------------------------------------------ //
27
use Xmf\Request;
28
use XoopsModules\Planet;
29
/** @var Planet\Helper $helper */
30
$helper = Planet\Helper::getInstance();
31
32
$xoopsOption['pagetype'] = 'search';
33
include __DIR__ . '/header.php';
34
$xoopsModule->loadLanguage('main');
35
$configHandler     = xoops_getHandler('config');
36
$xoopsConfigSearch = $configHandler->getConfigsByCat(XOOPS_CONF_SEARCH);
37
if (empty($xoopsConfigSearch['enable_search'])) {
38
    redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php', 2, planet_constant('MD_NOACCESS'));
39
}
40
41
$xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0;
42
$xoopsOption['template_main']                             = PlanetUtility::planetGetTemplate('search');
43
include XOOPS_ROOT_PATH . '/header.php';
44
include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
45
46
require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/search.inc.php';
47
$limit = $helper->getConfig('articles_perpage');
48
49
$queries  = [];
50
$andor    = Request::getString('andor', Request::getString('andor', '', 'GET'), 'POST');//isset($_POST['andor']) ? $_POST['andor'] : (isset($_GET['andor']) ? $_GET['andor'] : '');
51
$start    = Request::getInt('start', 0, 'GET');//isset($_GET['start']) ? $_GET['start'] : 0;
52
$category = Request::getInt('category', Request::getInt('category', 0, 'GET'), 'POST'); //(int)(isset($_POST['category']) ? $_POST['category'] : (isset($_GET['category']) ? $_GET['category'] : null));
53
$blog     = Request::getInt('blog', Request::getInt('blog', 0, 'GET'), 'POST');//(int)(isset($_POST['blog']) ? $_POST['blog'] : (isset($_GET['blog']) ? $_GET['blog'] : null));
54
$uid      = Request::getInt('uid', Request::getInt('uid', 0, 'GET'), 'POST');//(int)(isset($_POST['uid']) ? $_POST['uid'] : (isset($_GET['uid']) ? $_GET['uid'] : null));
55
$searchin = Request::getArray(
56
    'searchin',
57
    0 !== count(Request::getArray('searchin', [], 'GET')) ? explode('|', Request::getArray('searchin', [], 'GET')) : [],
58
                              'POST'
59
); //isset($_POST['searchin']) ? $_POST['searchin'] : (isset($_GET['searchin']) ? explode('|', $_GET['searchin']) : array());
60
$sortby   = Request::getString('sortby', Request::getString('sortby', null, 'GET'), 'POST');//isset($_POST['sortby']) ? $_POST['sortby'] : (isset($_GET['sortby']) ? $_GET['sortby'] : null);
61
$term     = Request::getString('term', Request::getString('term', '', 'GET'), 'POST');//isset($_POST['term']) ? $_POST['term'] : (isset($_GET['term']) ? $_GET['term'] : '');
62
63
$andor  = in_array(strtoupper($andor), ['OR', 'AND', 'EXACT']) ? strtoupper($andor) : 'OR';
64
$sortby = in_array(strtolower($sortby), [
65
    'a.art_id desc',
66
    'a.art_time desc',
67
    'a.art_title',
68
    'a.blog_id',
69
    'b.blog_id',
70
    'b.blog_feed',
71
    'b.blog_title',
72
    'b.blog_time'
73
]) ? strtolower($sortby) : '';
74
75
if (!(empty(Request::getString('submit', '', 'POST')) && empty(Request::getString('term', '', 'GET')))) {
76
    $next_search['category'] = $category;
77
    $next_search['blog']     = $blog;
78
    $next_search['uid']      = $uid;
79
    $next_search['andor']    = $andor;
80
81
    $next_search['term'] = $term;
82
    $query               = trim($term);
83
84
    if ('EXACT' !== $andor) {
85
        $ignored_queries = []; // holds kewords that are shorter than allowed minmum length
86
        $temp_queries    = preg_split("/[\s,]+/", $query);
87
        foreach ($temp_queries as $q) {
88
            $q = trim($q);
89
            if (strlen($q) >= $xoopsConfigSearch['keyword_min']) {
90
                $queries[] = $myts->addSlashes($q);
91
            } else {
92
                $ignored_queries[] = $myts->addSlashes($q);
93
            }
94
        }
95 View Code Duplication
        if (0 == count($queries)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
96
            redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min']));
97
        }
98
    } else {
99 View Code Duplication
        if (strlen($query) < $xoopsConfigSearch['keyword_min']) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
100
            redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min']));
101
        }
102
        $queries = [$myts->addSlashes($query)];
103
    }
104
105
    $next_search['sortby']   = $sortby;
106
    $next_search['searchin'] = implode('|', $searchin);
107
108
    /* To be added: year-month
109
     * see view.archive.php
110
     */
111
    if (!empty($time)) {
112
        $extra = '';
113
    } else {
114
        $extra = '';
115
    }
116
117
    $results = planet_search($queries, $andor, $limit, $start, $uid, $category, $blog, $sortby, $searchin, $extra);
118
119
    /*
120
    if ( count($results) < 1 ) {
121
        redirect_header("javascript:history.go(-1);", 2, _SR_NOMATCH);
122
    } else
123
    */
124
    {
125
        $xoopsTpl->assign('results', $results);
126
127
        if (count($next_search) > 0) {
128
            $items = [];
129
            foreach ($next_search as $para => $val) {
130
                if (!empty($val)) {
131
                    $items[] = "$para=$val";
132
                }
133
            }
134
            if (count($items) > 0) {
135
                $paras = implode('&', $items);
136
            }
137
            unset($next_search);
138
            unset($items);
139
        }
140
        $search_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php?' . $paras;
141
142
        /*
143
         $next_results =& planet_search($queries, $andor, 1, $start + $limit, $uid, $category, $sortby, $searchin, $extra);
144
      $next_count = count($next_results);
145
      $has_next = false;
146
      if (is_array($next_results) && $next_count >0) {
147
          $has_next = true;
148
      }
149
      if (false != $has_next)
150
      */
151
        if (count($results)) {
152
            $next            = $start + $limit;
153
            $queries         = implode(',', $queries);
154
            $search_url_next = $search_url . "&start=$next";
155
            $search_next     = '<a href="' . htmlspecialchars($search_url_next, ENT_QUOTES | ENT_HTML5) . '">' . _SR_NEXT . '</a>';
156
            $xoopsTpl->assign('search_next', $search_next);
157
        }
158
        if ($start > 0) {
159
            $prev            = $start - $limit;
160
            $search_url_prev = $search_url . "&start=$prev";
161
            $search_prev     = '<a href="' . htmlspecialchars($search_url_prev, ENT_QUOTES | ENT_HTML5) . '">' . _SR_PREVIOUS . '</a>';
162
            $xoopsTpl->assign('search_prev', $search_prev);
163
        }
164
    }
165
166
    unset($results);
167
    $search_info = _SR_KEYWORDS . ': ' . $myts->htmlSpecialChars($term);
168
    $xoopsTpl->assign('search_info', $search_info);
169
}
170
171
/* type */
172
$type_select = '<select name="andor">';
173
$type_select .= '<option value="OR"';
174
if ('OR' === $andor) {
175
    $type_select .= ' selected="selected"';
176
}
177
$type_select .= '>' . _SR_ANY . '</option>';
178
$type_select .= '<option value="AND"';
179
if ('AND' === $andor) {
180
    $type_select .= ' selected="selected"';
181
}
182
$type_select .= '>' . _SR_ALL . '</option>';
183
$type_select .= '<option value="EXACT"';
184
if ('exact' === $andor) {
185
    $type_select .= ' selected="selected"';
186
}
187
$type_select .= '>' . _SR_EXACT . '</option>';
188
$type_select .= '</select>';
189
190
/* scope */
191
$searchin_select = '';
192
$searchin_select .= '<input type="checkbox" name="searchin[]" value="title"';
193
if (in_array('title', $searchin)) {
194
    $searchin_select .= ' checked';
195
}
196
$searchin_select .= '>' . planet_constant('MD_TITLE') . '&nbsp;&nbsp;';
197
$searchin_select .= '<input type="checkbox" name="searchin[]" value="text"';
198
if (in_array('text', $searchin)) {
199
    $searchin_select .= ' checked';
200
}
201
$searchin_select .= '>' . planet_constant('MD_BODY') . '&nbsp;&nbsp;||&nbsp;&nbsp;';
202
$searchin_select .= '<input type="checkbox" name="searchin[]" value="blog"';
203
if (in_array('blog', $searchin)) {
204
    $searchin_select .= ' checked';
205
}
206
$searchin_select .= '>' . planet_constant('MD_BLOG') . '&nbsp;&nbsp;';
207
$searchin_select .= '<input type="checkbox" name="searchin[]" value="feed"';
208
if (in_array('feed', $searchin)) {
209
    $searchin_select .= ' checked';
210
}
211
$searchin_select .= '>' . planet_constant('MD_FEED') . '&nbsp;&nbsp;';
212
$searchin_select .= '<input type="checkbox" name="searchin[]" value="desc"';
213
if (in_array('desc', $searchin)) {
214
    $searchin_select .= ' checked';
215
}
216
$searchin_select .= '>' . planet_constant('MD_DESC') . '&nbsp;&nbsp;';
217
$searchin_select .= '<input type="checkbox" name="searchin[]" value="all"';
218
if (empty($searchin)) {
219
    $searchin_select .= ' checked';
220
}
221
$searchin_select .= '>' . _ALL . '&nbsp;&nbsp;';
222
223
/* sortby */
224
$sortby_select = '<select name="sortby">';
225
$sortby_select .= '<option value=""';
226
if (empty($sortby)) {
227
    $sortby_select .= ' selected="selected"';
228
}
229
$sortby_select .= '>' . _NONE . '</option>';
230
$sortby_select .= '<option value="a.art_time"';
231
if ('a.art_time' === $sortby) {
232
    $sortby_select .= ' selected="selected"';
233
}
234
$sortby_select .= '>' . planet_constant('MD_TIME') . '</option>';
235
$sortby_select .= '<option value="a.art_title"';
236
if ('a.art_title' === $sortby) {
237
    $sortby_select .= ' selected="selected"';
238
}
239
$sortby_select .= '>' . planet_constant('MD_TITLE') . '</option>';
240
$sortby_select .= '<option value="">&nbsp;&nbsp;----&nbsp;&nbsp;</option>';
241
$sortby_select .= '<option value="a.blog_title"';
242
if ('a.blog_title' === $sortby) {
243
    $sortby_select .= ' selected="selected"';
244
}
245
$sortby_select .= '>' . planet_constant('MD_BLOG') . '</option>';
246
$sortby_select .= '<option value="a.blog_time"';
247
if ('b.blog_time' === $sortby) {
248
    $sortby_select .= ' selected="selected"';
249
}
250
$sortby_select .= '>' . planet_constant('MD_UPDATE') . '</option>';
251
$sortby_select .= '</select>';
252
253
$xoopsTpl->assign('type_select', $type_select);
254
$xoopsTpl->assign('searchin_select', $searchin_select);
255
$xoopsTpl->assign('sortby_select', $sortby_select);
256
$xoopsTpl->assign('search_term', $term);
257
258
$xoopsTpl->assign('modname', $xoopsModule->getVar('name'));
259
260
$xoopsTpl->assign('category', $category);
261
$xoopsTpl->assign('blog', $blog);
262
$xoopsTpl->assign('uid', $uid);
263
264
if ($xoopsConfigSearch['keyword_min'] > 0) {
265
    $xoopsTpl->assign('search_rule', sprintf(_SR_KEYIGNORE, $xoopsConfigSearch['keyword_min']));
266
}
267
268
include XOOPS_ROOT_PATH . '/footer.php';
269