Issues (67)

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.

class/Contents.php (1 issue)

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Xoopsfaq;
4
5
/*
6
 You may not change or alter any portion of this comment or credits of
7
 supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit
9
 authors.
10
11
 This program is distributed in the hope that it will be useful, but
12
 WITHOUT ANY WARRANTY; without even the implied warranty of
13
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 */
15
16
/**
17
 * Contents (FAQ) and Handler Class Definitions
18
 *
19
 * @author    John Neill
20
 * @author    XOOPS Module Development Team
21
 * @copyright Copyright (c) 2001-2017 {@link https://xoops.org XOOPS Project}
22
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GNU Public License
23
 * @since     ::   1.23
24
 */
25
26
use Xmf\Module\Admin;
27
28
/**
29
 * Contents handles CRUD operations for FAQs
30
 *
31
 * @author   ::    John Neill
32
 * @copyright:: Copyright (c) 2009
33
 */
34
final class Contents extends \XoopsObject
35
{
36
    private int    $contents_id;
37
    private int    $contents_cid;
38
    private string $contents_title;
39
    private string $contents_contents;
40
    private int    $contents_publish;
41
    private int    $contents_weight;
42
    private int    $contents_active;
43
    private int    $dohtml;
44
    private int    $doxcode;
45
    private int    $dosmiley;
46
    private int    $doimage;
47
    private int    $dobr;
48
    /**
49
     * @var string contains this modules directory name
50
     */
51
    protected string $dirname;
52
53
    /**
54
     * Constructor
55
     */
56
    public function __construct()
57
    {
58
        $this->dirname = \basename(\dirname(__DIR__));
59
        \xoops_load('constants', $this->dirname);
60
61
        parent::__construct();
62
        $this->initVar('contents_id', \XOBJ_DTYPE_INT, null, false);
63
        $this->initVar('contents_cid', \XOBJ_DTYPE_INT, Constants::DEFAULT_CATEGORY, false);
64
        $this->initVar('contents_title', \XOBJ_DTYPE_TXTBOX, null, true, 255);
65
        $this->initVar('contents_contents', \XOBJ_DTYPE_TXTAREA, null, false);
66
        $this->initVar('contents_publish', \XOBJ_DTYPE_INT, \time(), false);
67
        $this->initVar('contents_weight', \XOBJ_DTYPE_INT, Constants::DEFAULT_WEIGHT, false);
68
        $this->initVar('contents_active', \XOBJ_DTYPE_INT, Constants::ACTIVE, false);
69
        $this->initVar('dohtml', \XOBJ_DTYPE_INT, Constants::SET, false);
70
        $this->initVar('doxcode', \XOBJ_DTYPE_INT, Constants::SET, false);
71
        $this->initVar('dosmiley', \XOBJ_DTYPE_INT, Constants::SET, false);
72
        $this->initVar('doimage', \XOBJ_DTYPE_INT, Constants::SET, false);
73
        $this->initVar('dobr', \XOBJ_DTYPE_INT, Constants::SET, false);
74
    }
75
76
    /**
77
     * Display Content (FAQ)
78
     *
79
     * @return string
80
     */
81
    public function __toString(): string
82
    {
83
        return (string)$this->getVar('contents_title', 's');
84
    }
85
86
    /**
87
     * Display the Content (FAQ) Editor form for Admin
88
     */
89
    public function displayForm(): void
90
    {
91
        echo $this->renderForm();
92
    }
93
94
    /**
95
     * Displays the Content (FAQ) Editor form for Admin
96
     */
97
    public function renderForm()
98
    {
99
        /** @var Helper $helper */
100
        $helper = Helper::getHelper($this->dirname);
101
        /** @var CategoryHandler $categoryHandler */
102
        $categoryHandler = $helper->getHandler('Category');
103
        $catCount        = $categoryHandler->getCount();
104
        if (empty($catCount)) {
105
            \xoops_error(\_AM_XOOPSFAQ_ERROR_NO_CATS_EXIST, '');
106
            \xoops_cp_footer();
107
            exit();
108
        }
109
110
        require_once \dirname(__DIR__, 3) . '/class/xoopsformloader.php';
111
112
        if ($this->isNew()) {
113
            $caption = \_AM_XOOPSFAQ_CREATE_NEW;
114
        } else {
115
            $contentsTitle = $this->getVar('contents_title');
116
            if (\is_scalar($contentsTitle)) {
117
                $caption = \sprintf(\_AM_XOOPSFAQ_MODIFY_ITEM, $contentsTitle);
118
            } else {
119
                $caption = '';
120
            }
121
        }
122
123
        $form = new \XoopsThemeForm($caption, 'content', $_SERVER['REQUEST_URI'], 'post', true);
124
        //        $form->addElement(new \XoopsFormHiddenToken());
125
        $form->addElement(new \XoopsFormHidden('op', 'save'));
126
        $form->addElement(new \XoopsFormHidden('contents_id', $this->getVar('contents_id', 'e')));
127
128
        // Active
129
        $contents_active = new \XoopsFormRadioYN(\_AM_XOOPSFAQ_E_CONTENTS_ACTIVE, 'contents_active', $this->getVar('contents_active', 'e'), ' ' . \_YES, ' ' . \_NO);
130
        $contents_active->setDescription(\_AM_XOOPSFAQ_E_CONTENTS_ACTIVE_DESC);
131
        $form->addElement($contents_active, false);
132
133
        // Title
134
        $contents_title = new \XoopsFormText(\_AM_XOOPSFAQ_E_CONTENTS_TITLE, 'contents_title', 50, 150, $this->getVar('contents_title', 'e'));
135
        $contents_title->setDescription(\_AM_XOOPSFAQ_E_CONTENTS_TITLE_DESC);
136
        $form->addElement($contents_title, true);
137
138
        // Category
139
        $catCriteria        = new \CriteriaCompo();
140
        $catCriteria->order = 'ASC';
141
        $catCriteria->setSort('category_order');
142
        $objects      = $categoryHandler->getList($catCriteria);
143
        $contents_cid = new \XoopsFormSelect(\_AM_XOOPSFAQ_E_CONTENTS_CATEGORY, 'contents_cid', $this->getVar('contents_cid', 'e'), 1, false);
144
        $contents_cid->setDescription(\_AM_XOOPSFAQ_E_CONTENTS_CATEGORY_DESC);
145
        $contents_cid->addOptionArray($objects);
146
        $form->addElement($contents_cid);
147
148
        // Weight
149
        $contents_weight = new \XoopsFormText(\_AM_XOOPSFAQ_E_CONTENTS_WEIGHT, 'contents_weight', 5, 5, $this->getVar('contents_weight', 'e'));
150
        $contents_weight->setDescription(\_AM_XOOPSFAQ_E_CONTENTS_WEIGHT_DESC);
151
        $form->addElement($contents_weight, false);
152
153
        // Editor
154
        $editorConfigs = [];
155
        $options_tray  = new \XoopsFormElementTray(\_AM_XOOPSFAQ_E_CONTENTS_CONTENT, '<br>');
156
        if (\class_exists('XoopsFormEditor')) {
157
            // $editorConfigs = array('editor' => $GLOBALS['xoopsConfig']['general_editor'],
158
            $editorConfigs     = [
159
                'editor' => $helper->getConfig('use_wysiwyg', 'dhtmltextarea'),
160
                'rows'   => 25,
161
                'cols'   => '100%',
162
                'width'  => '100%',
163
                'height' => '600px',
164
                'name'   => 'contents_contents',
165
                'value'  => $this->getVar('contents_contents', 'e'),
166
            ];
167
            $contents_contents = new \XoopsFormEditor('', 'contents_contents', $editorConfigs);
168
        } else {
169
            $contents_contents = new \XoopsFormDhtmlTextArea('', 'contents_contents', $this->getVar('contents_contents', 'e'), '100%', '100%');
170
        }
171
        $options_tray->addElement($contents_contents);
172
        $options_tray->setDescription(\_AM_XOOPSFAQ_E_CONTENTS_CONTENT_DESC);
173
174
        \xoops_load('XoopsEditorHandler');
175
        $editorHandler = \XoopsEditorHandler::getInstance();
176
        $editorList    = $editorHandler->getList(true);
177
        if (isset($editorConfigs['editor']) && \in_array($editorConfigs['editor'], \array_flip($editorList), true)) {
178
            $form->addElement(new \XoopsFormHidden('dohtml', (string)Constants::NOTSET));
179
            $form->addElement(new \XoopsFormHidden('dobr', (string)Constants::SET));
180
        } else {
181
            $html_checkbox = new \XoopsFormCheckBox('', 'dohtml', $this->getVar('dohtml', 'e'));
182
            $html_checkbox->addOption('1', \_AM_XOOPSFAQ_E_DOHTML);
183
            $options_tray->addElement($html_checkbox);
184
185
            $breaks_checkbox = new \XoopsFormCheckBox('', 'dobr', $this->getVar('dobr', 'e'));
186
            $breaks_checkbox->addOption('1', \_AM_XOOPSFAQ_E_BREAKS);
187
            $options_tray->addElement($breaks_checkbox);
188
        }
189
190
        $doimage_checkbox = new \XoopsFormCheckBox('', 'doimage', $this->getVar('doimage', 'e'));
191
        $doimage_checkbox->addOption('1', \_AM_XOOPSFAQ_E_DOIMAGE);
192
        $options_tray->addElement($doimage_checkbox);
193
194
        $xcodes_checkbox = new \XoopsFormCheckBox('', 'doxcode', $this->getVar('doxcode', 'e'));
195
        $xcodes_checkbox->addOption('1', \_AM_XOOPSFAQ_E_DOXCODE);
196
        $options_tray->addElement($xcodes_checkbox);
197
198
        $smiley_checkbox = new \XoopsFormCheckBox('', 'dosmiley', $this->getVar('dosmiley', 'e'));
199
        $smiley_checkbox->addOption('1', \_AM_XOOPSFAQ_E_DOSMILEY);
200
        $options_tray->addElement($smiley_checkbox);
201
202
        $form->addElement($options_tray);
203
204
        $contents_publish = new \XoopsFormTextDateSelect(\_AM_XOOPSFAQ_E_CONTENTS_PUBLISH, 'contents_publish', 20, (int)$this->getVar('contents_publish'), $this->isNew());
0 ignored issues
show
The call to XoopsFormTextDateSelect::__construct() has too many arguments starting with $this->isNew(). ( Ignorable by Annotation )

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

204
        $contents_publish = /** @scrutinizer ignore-call */ new \XoopsFormTextDateSelect(\_AM_XOOPSFAQ_E_CONTENTS_PUBLISH, 'contents_publish', 20, (int)$this->getVar('contents_publish'), $this->isNew());

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
205
        $contents_publish->setDescription(\_AM_XOOPSFAQ_E_CONTENTS_PUBLISH_DESC);
206
        $form->addElement($contents_publish);
207
208
        $form->addElement(new \XoopsFormButtonTray('contents_form', \_SUBMIT, 'submit'));
209
210
        return $form->render();
211
    }
212
213
    /**
214
     * Get the FAQ Active/Inactive icon to display
215
     *
216
     * @return string HTML <img> tag representing current active status
217
     */
218
    public function getActiveIcon(): string
219
    {
220
        if ($this->getVar('contents_active') > Constants::INACTIVE) {
221
            $icon = '<img src="' . Admin::iconUrl('green.gif', '16') . '" alt="' . \_YES . '">';
222
        } else {
223
            $icon = '<img src="' . Admin::iconUrl('red.gif', '16') . '" alt="' . \_NO . '">';
224
        }
225
226
        return $icon;
227
    }
228
229
    /**
230
     * Get the timestamp for when Content (FAQ) was published
231
     *
232
     * @param int|string $timestamp Unix timestamp
233
     *
234
     * @return string formatted timestamp on success, false on failure
235
     */
236
    public function getPublished($timestamp = ''): string
237
    {
238
        if (!$this->getVar('contents_publish')) {
239
            return '';
240
        }
241
242
        return \formatTimestamp($this->getVar('contents_publish'), $timestamp);
243
    }
244
}
245