Issues (496)

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.

class/Customtag.php (1 issue)

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 namespace XoopsModules\Smartobject;
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 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @package
17
 * @since
18
 * @author     XOOPS Development Team
19
 */
20
21
use XoopsModules\Smartobject;
22
23
// defined('XOOPS_ROOT_PATH') || die('Restricted access');
24
25
//require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php';
26
27
/**
28
 * Class SmartobjectCustomtag
29
 */
30
class Customtag extends Smartobject\BaseSmartObject
31
{
32
    public $content = false;
33
34
    /**
35
     * SmartobjectCustomtag constructor.
36
     */
37
    public function __construct()
38
    {
39
        $this->quickInitVar('customtagid', XOBJ_DTYPE_INT, true);
40
        $this->quickInitVar('name', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_NAME, _CO_SOBJECT_CUSTOMTAG_NAME_DSC);
41
        $this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION, _CO_SOBJECT_CUSTOMTAG_DESCRIPTION_DSC);
42
        $this->quickInitVar('content', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_CUSTOMTAG_CONTENT, _CO_SOBJECT_CUSTOMTAG_CONTENT_DSC);
43
        $this->quickInitVar('language', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_CUSTOMTAG_LANGUAGE, _CO_SOBJECT_CUSTOMTAG_LANGUAGE_DSC);
44
45
        $this->initNonPersistableVar('dohtml', XOBJ_DTYPE_INT, 'class', 'dohtml', '', true);
46
        $this->initNonPersistableVar('doimage', XOBJ_DTYPE_INT, 'class', 'doimage', '', true);
47
        $this->initNonPersistableVar('doxcode', XOBJ_DTYPE_INT, 'class', 'doxcode', '', true);
48
        $this->initNonPersistableVar('dosmiley', XOBJ_DTYPE_INT, 'class', 'dosmiley', '', true);
49
50
        $this->setControl('content', [
51
            'name'        => 'textarea',
52
            'form_editor' => 'textarea',
53
            'form_rows'   => 25
54
        ]);
55
        $this->setControl('language', [
56
            'name' => 'language',
57
            'all'  => true
58
        ]);
59
    }
60
61
    /**
62
     * @param  string $key
63
     * @param  string $format
64
     * @return mixed
65
     */
66
    public function getVar($key, $format = 's')
67
    {
68
        if ('s' === $format && in_array($key, [])) {
69
            //            return call_user_func(array($this, $key));
70
            return $this->{$key}();
71
        }
72
73
        return parent::getVar($key, $format);
74
    }
75
76
    /**
77
     * @return bool|mixed
78
     */
79
    public function render()
80
    {
81
        if (!$this->content) {
82
            $ret           = $this->getVar('content');
83
            $this->content = $ret;
84
        }
85
86
        return $this->content;
87
    }
88
89
    /**
90
     * @return bool|mixed|string
91
     */
92
    public function renderWithPhp()
93
    {
94
        if (!$this->content) {
95
            $ret           = $this->getVar('content');
96
            $this->content = $ret;
97
        } else {
98
            $ret = $this->content;
99
        }
100
101
        // check for PHP if we are not on admin side
102
        if (!defined('XOOPS_CPFUNC_LOADED') && !(false === strpos($ret, '[php]'))) {
103
            $ret = str_replace('[php]', '', $ret);
104
            // we have PHP code, let's evaluate
105
            eval($ret);
106
107
            return '';
108
        }
109
110
        return $this->content;
111
    }
112
113
    /**
114
     * @return string
115
     */
116
    public function getXoopsCode()
117
    {
118
        $ret = '[customtag]' . $this->getVar('tag', 'n') . '[/customtag]';
119
120
        return $ret;
121
    }
122
123
    /**
124
     * @return string
125
     */
126
    public function getCloneLink()
127
    {
128
        $ret = '<a href="' . SMARTOBJECT_URL . 'admin/customtag.php?op=clone&customtagid=' . $this->id() . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" style="vertical-align: middle;" alt="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '" title="' . _CO_SOBJECT_CUSTOMTAG_CLONE . '"></a>';
129
130
        return $ret;
131
    }
132
133
    /**
134
     * @param $var
135
     * @return bool
136
     */
137
    public function emptyString($var)
138
    {
139
        return (strlen($var) > 0);
140
    }
141
142
    /**
143
     * @return mixed|string
144
     */
145 View Code Duplication
    public function generateTag()
0 ignored issues
show
This method seems to be duplicated in 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...
146
    {
147
        $title = rawurlencode(strtolower($this->getVar('description', 'e')));
148
        $title = xoops_substr($title, 0, 10, '');
149
        // Transformation des ponctuations
150
        $pattern = [
151
            '/%09/', // Tab
152
            '/%20/', // Space
153
            '/%21/', // !
154
            '/%22/', // "
155
            '/%23/', // #
156
            '/%25/', // %
157
            '/%26/', // &
158
            '/%27/', // '
159
            '/%28/', // (
160
            '/%29/', // )
161
            '/%2C/', // ,
162
            '/%2F/', // /
163
            '/%3A/', // :
164
            '/%3B/', // ;
165
            '/%3C/', // <
166
            '/%3D/', // =
167
            '/%3E/', // >
168
            '/%3F/', // ?
169
            '/%40/', // @
170
            '/%5B/', // [
171
            '/%5C/', // \
172
            '/%5D/', // ]
173
            '/%5E/', // ^
174
            '/%7B/', // {
175
            '/%7C/', // |
176
            '/%7D/', // }
177
            '/%7E/', // ~
178
            "/\./" // .
179
        ];
180
        $rep_pat = [
181
            '-',
182
            '-',
183
            '-',
184
            '-',
185
            '-',
186
            '-100',
187
            '-',
188
            '-',
189
            '-',
190
            '-',
191
            '-',
192
            '-',
193
            '-',
194
            '-',
195
            '-',
196
            '-',
197
            '-',
198
            '-',
199
            '-at-',
200
            '-',
201
            '-',
202
            '-',
203
            '-',
204
            '-',
205
            '-',
206
            '-',
207
            '-',
208
            '-'
209
        ];
210
        $title   = preg_replace($pattern, $rep_pat, $title);
211
212
        // Transformation des caractères accentués
213
        $pattern = [
214
            '/%B0/', // °
215
            '/%E8/', // è
216
            '/%E9/', // é
217
            '/%EA/', // ê
218
            '/%EB/', // ë
219
            '/%E7/', // ç
220
            '/%E0/', // à
221
            '/%E2/', // â
222
            '/%E4/', // ä
223
            '/%EE/', // î
224
            '/%EF/', // ï
225
            '/%F9/', // ù
226
            '/%FC/', // ü
227
            '/%FB/', // û
228
            '/%F4/', // ô
229
            '/%F6/', // ö
230
        ];
231
        $rep_pat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
232
        $title   = preg_replace($pattern, $rep_pat, $title);
233
234
        $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
235
        $tableau = array_filter($tableau, [$this, 'emptyString']); // Supprime les chaines vides du tableau
236
        $title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
237
238
        $title .= time();
239
        $title = md5($title);
240
241
        return $title;
242
    }
243
244
    /**
245
     * @return mixed
246
     */
247
    public function getCustomtagName()
248
    {
249
        $ret = $this->getVar('name');
250
251
        return $ret;
252
    }
253
}
254