Issues (964)

Security Analysis    not enabled

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

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

testdata/mymodule/include/functions.php (16 issues)

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
 * My Module module for xoops
14
 *
15
 * @copyright     2020 XOOPS Project (https://xooops.org)
16
 * @license        GPL 2.0 or later
17
 * @package        mymodule
18
 * @since          1.0
19
 * @min_xoops      2.5.9
20
 * @author         TDM XOOPS - Email:<[email protected]> - Website:<http://xoops.org>
21
 */
22
23
/***************Blocks***************/
24
25
/**
26
 * add selected cats
27
 * @param $cats
28
 * @return string
29
 */
30
function mymodule_block_addCatSelect($cats) {
31
    if(is_array($cats))
32
    {
33
        $cat_sql = '('.current($cats);
34
        array_shift($cats);
35
        foreach($cats as $cat)
36
        {
37
            $cat_sql .= ','.$cat;
38
        }
39
        $cat_sql .= ')';
40
    }
41
    return $cat_sql;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $cat_sql does not seem to be defined for all execution paths leading up to this point.
Loading history...
42
}
43
44
/**
45
 * Get the permissions ids
46
 * @param $permtype
47
 * @param $dirname
48
 * @return mixed $articles
49
 */
50
function mymoduleGetMyItemIds($permtype, $dirname)
51
{
52
    global $xoopsUser;
53
    static $permissions = array();
54
    if(is_array($permissions) && array_key_exists($permtype, $permissions)) {
55
        return $permissions[$permtype];
56
    }
57
	$moduleHandler = xoops_getHandler('module');
58
	$mymoduleModule = $moduleHandler->getByDirname($dirname);
0 ignored issues
show
The method getByDirname() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

58
	/** @scrutinizer ignore-call */ 
59
 $mymoduleModule = $moduleHandler->getByDirname($dirname);
Loading history...
59
	$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
60
	$gpermHandler = xoops_getHandler('groupperm');
61
	$articles = $gpermHandler->getItemIds($permtype, $groups, $mymoduleModule->getVar('mid'));
0 ignored issues
show
The method getItemIds() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

61
	/** @scrutinizer ignore-call */ 
62
 $articles = $gpermHandler->getItemIds($permtype, $groups, $mymoduleModule->getVar('mid'));
Loading history...
62
    return $articles;
63
}
64
65
/**
66
 * Get the number of articles from the sub categories of a category or sub topics of or topic
67
 * @param $mytree
68
 * @param $articles
69
 * @param $entries
70
 * @param $cid
71
 * @return int
72
 */
73
function mymoduleNumbersOfEntries($mytree, $articles, $entries, $cid)
74
{
75
    $count = 0;
76
    if(in_array($cid, $articles)) {
77
        $child = $mytree->getAllChild($cid);
78
        foreach (array_keys($entries) as $i) {
79
            if ($entries[$i]->getVar('art_id') == $cid){
80
                $count++;
81
            }
82
            foreach (array_keys($child) as $j) {
83
                if ($entries[$i]->getVar('art_id') == $j){
84
                    $count++;
85
                }
86
            }
87
        }
88
    }
89
    return $count;
90
}
91
92
/**
93
 * Add content as meta tag to template
94
 * @param $content
95
 * @return void
96
 */
97
98
function mymoduleMetaKeywords($content)
99
{
100
    global $xoopsTpl, $xoTheme;
101
    $myts = MyTextSanitizer::getInstance();
102
    $content= $myts->undoHtmlSpecialChars($myts->displayTarea($content));
103
    if(isset($xoTheme) && is_object($xoTheme)) {
104
        $xoTheme->addMeta( 'meta', 'keywords', strip_tags($content));
105
    } else {    // Compatibility for old Xoops versions
106
        $xoopsTpl->assign('xoops_meta_keywords', strip_tags($content));
107
    }
108
}
109
110
/**
111
 * Add content as meta description to template
112
 * @param $content
113
 * @return void
114
 */
115
 
116
function mymoduleMetaDescription($content)
117
{
118
    global $xoopsTpl, $xoTheme;
119
    $myts = MyTextSanitizer::getInstance();
120
    $content = $myts->undoHtmlSpecialChars($myts->displayTarea($content));
121
    if(isset($xoTheme) && is_object($xoTheme)) {
122
        $xoTheme->addMeta( 'meta', 'description', strip_tags($content));
123
    } else {    // Compatibility for old Xoops versions
124
        $xoopsTpl->assign('xoops_meta_description', strip_tags($content));
125
    }
126
}
127
128
/**
129
 * Rewrite all url
130
 *
131
 * @param string  $module  module name
132
 * @param array   $array   array
133
 * @param string  $type    type
134
 * @return null|string $type    string replacement for any blank case
135
 */
136
function mymodule_RewriteUrl($module, $array, $type = 'content')
137
{
138
    $comment = '';
139
    $helper = \XoopsModules\Mymodule\Helper::getInstance();
140
    $articles = $helper->getHandler('articles');
0 ignored issues
show
The assignment to $articles is dead and can be removed.
Loading history...
141
    $lenght_id = $helper->getConfig('lenght_id');
142
    $rewrite_url = $helper->getConfig('rewrite_url');
143
144
    if ($lenght_id != 0) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $lenght_id of type mixed|null to 0; this is ambiguous as not only 0 == 0 is true, but null == 0 is true, too. Consider using a strict comparison ===.
Loading history...
145
        $id = $array['content_id'];
146
        while (strlen($id) < $lenght_id) {
147
            $id = '0' . $id;
148
        }
149
    } else {
150
        $id = $array['content_id'];
151
    }
152
153
    if (isset($array['topic_alias']) && $array['topic_alias']) {
154
        $topic_name = $array['topic_alias'];
155
    } else {
156
        $topic_name = mymodule_Filter(xoops_getModuleOption('static_name', $module));
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

156
        $topic_name = mymodule_Filter(/** @scrutinizer ignore-deprecated */ xoops_getModuleOption('static_name', $module));
Loading history...
157
    }
158
159
    switch ($rewrite_url) {
160
161
        case 'none':
162
            if($topic_name) {
163
                 $topic_name = 'topic=' . $topic_name . '&amp;';
164
            }
165
            $rewrite_base = '/modules/';
166
            $page = 'page=' . $array['content_alias'];
167
            return XOOPS_URL . $rewrite_base . $module . '/' . $type . '.php?' . $topic_name . 'id=' . $id . '&amp;' . $page . $comment;
168
            break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
169
170
        case 'rewrite':
171
            if($topic_name) {
172
                $topic_name .= '/';
173
            }
174
            $rewrite_base = xoops_getModuleOption('rewrite_mode', $module);
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

174
            $rewrite_base = /** @scrutinizer ignore-deprecated */ xoops_getModuleOption('rewrite_mode', $module);
Loading history...
175
            $rewrite_ext = xoops_getModuleOption('rewrite_ext', $module);
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

175
            $rewrite_ext = /** @scrutinizer ignore-deprecated */ xoops_getModuleOption('rewrite_ext', $module);
Loading history...
176
            $module_name = '';
177
            if(xoops_getModuleOption('rewrite_name', $module)) {
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

177
            if(/** @scrutinizer ignore-deprecated */ xoops_getModuleOption('rewrite_name', $module)) {
Loading history...
178
                $module_name = xoops_getModuleOption('rewrite_name', $module) . '/';
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

178
                $module_name = /** @scrutinizer ignore-deprecated */ xoops_getModuleOption('rewrite_name', $module) . '/';
Loading history...
179
            }
180
            $page = $array['content_alias'];
181
            $type .= '/';
182
            $id .= '/';
183
            if ($type === 'content/') {
184
                $type = '';
185
            }
186
            if ($type === 'comment-edit/' || $type === 'comment-reply/' || $type === 'comment-delete/') {
187
                return XOOPS_URL . $rewrite_base . $module_name . $type . $id . '/';
188
            }
189
190
            return XOOPS_URL . $rewrite_base . $module_name . $type . $topic_name  . $id . $page . $rewrite_ext;
191
            break;
192
193
         case 'short':
194
            if($topic_name) {
195
                $topic_name .= '/';
196
            }
197
            $rewrite_base = xoops_getModuleOption('rewrite_mode', $module);
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

197
            $rewrite_base = /** @scrutinizer ignore-deprecated */ xoops_getModuleOption('rewrite_mode', $module);
Loading history...
198
            $rewrite_ext = xoops_getModuleOption('rewrite_ext', $module);
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

198
            $rewrite_ext = /** @scrutinizer ignore-deprecated */ xoops_getModuleOption('rewrite_ext', $module);
Loading history...
199
            $module_name = '';
200
            if(xoops_getModuleOption('rewrite_name', $module)) {
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

200
            if(/** @scrutinizer ignore-deprecated */ xoops_getModuleOption('rewrite_name', $module)) {
Loading history...
201
                $module_name = xoops_getModuleOption('rewrite_name', $module) . '/';
0 ignored issues
show
Deprecated Code introduced by
The function xoops_getModuleOption() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

201
                $module_name = /** @scrutinizer ignore-deprecated */ xoops_getModuleOption('rewrite_name', $module) . '/';
Loading history...
202
            }
203
            $page = $array['content_alias'];
204
            $type .= '/';
205
            if ($type === 'content/') {
206
                $type = '';
207
            }
208
            if ($type === 'comment-edit/' || $type === 'comment-reply/' || $type === 'comment-delete/') {
209
                return XOOPS_URL . $rewrite_base . $module_name . $type . $id . '/';
210
            }
211
212
            return XOOPS_URL . $rewrite_base . $module_name . $type . $topic_name . $page . $rewrite_ext;
213
            break;
214
    }
215
    return null;
216
}
217
/**
218
 * Replace all escape, character, ... for display a correct url
219
 *
220
 * @param string $url      string to transform
221
 * @param string $type     string replacement for any blank case
222
 * @return string $url
223
 */
224
function mymodule_Filter($url, $type = '') {
225
226
    // Get regular expression from module setting. default setting is : `[^a-z0-9]`i
227
    $helper = \XoopsModules\Mymodule\Helper::getInstance();
228
    $articles = $helper->getHandler('articles');
0 ignored issues
show
The assignment to $articles is dead and can be removed.
Loading history...
229
    $regular_expression = $helper->getConfig('regular_expression');
230
231
    $url = strip_tags($url);
232
    $url .= preg_replace("`\[.*\]`U", '', $url);
233
    $url .= preg_replace('`&(amp;)?#?[a-z0-9]+;`i', '-', $url);
234
    $url .= htmlentities($url, ENT_COMPAT, 'utf-8');
235
    $url .= preg_replace("`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig);`i", "\1", $url);
236
    $url .= preg_replace(array($regular_expression, "`[-]+`"), '-', $url);
237
    $url = ($url == '') ? $type : strtolower(trim($url, '-'));
238
    return $url;
239
}