Issues (384)

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.

include/storyform.inc.php (3 issues)

1
<?php declare(strict_types=1);
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
 * @copyright      {@link https://xoops.org/ XOOPS Project}
14
 * @license        {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @author         XOOPS Development Team
16
 */
17
18
use Xmf\Request;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Request. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
19
use XoopsModules\News;
20
use XoopsModules\News\Files;
21
use XoopsModules\News\NewsTopic;
22
use XoopsModules\Tag\FormTag;
23
24
$moduleDirName = \basename(\dirname(__DIR__));
25
xoops_load('utility', $moduleDirName);
26
xoops_loadLanguage('calendar');
27
28
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
29
require_once XOOPS_ROOT_PATH . '/modules/news/config.php';
30
31
if (!isset($subtitle)) {
32
    $subtitle = '';
33
}
34
35
$sform = new \XoopsThemeForm(_NW_SUBMITNEWS, 'storyform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/submit.php');
36
$sform->setExtra('enctype="multipart/form-data"');
37
$sform->addElement(new \XoopsFormText(_NW_TITLE, 'title', 50, 255, $title), true);
38
$sform->addElement(new \XoopsFormText(_NW_SUBTITLE, 'subtitle', 50, 255, $subtitle), false);
39
40
// Topic's selection box
41
if (!isset($xt)) {
42
    $xt = new NewsTopic();
43
}
44
if (0 == $xt->getAllTopicsCount()) {
45
    redirect_header('index.php', 4, _NW_POST_SORRY);
46
}
47
48
require_once XOOPS_ROOT_PATH . '/class/tree.php';
49
$allTopics  = $xt->getAllTopics($helper->getConfig('restrictindex'), 'news_submit');
50
$topic_tree = new \XoopsObjectTree($allTopics, 'topic_id', 'topic_pid');
51
52
if (News\Utility::checkVerXoops($GLOBALS['xoopsModule'], '2.5.9')) {
53
    $topic_select = $topic_tree->makeSelectElement('topic_id', 'topic_title', '--', $topicid, false, 0, '', _NW_TOPIC);
54
    $sform->addElement($topic_select);
55
} else {
56
    $topic_select = $topic_tree->makeSelBox('topic_id', 'topic_title', '-- ', $topicid, false);
0 ignored issues
show
Deprecated Code introduced by
The function XoopsObjectTree::makeSelBox() has been deprecated: since 2.5.9, please use makeSelectElement() ( Ignorable by Annotation )

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

56
    $topic_select = /** @scrutinizer ignore-deprecated */ $topic_tree->makeSelBox('topic_id', 'topic_title', '-- ', $topicid, false);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
57
    $sform->addElement(new \XoopsFormLabel(_NW_TOPIC, $topic_select));
58
}
59
60
//If admin - show admin form
61
//TODO: Change to "If submit privilege"
62
63
if ($approveprivilege) {
64
    //Show topic image?
65
    $sform->addElement(new \XoopsFormRadioYN(_AM_TOPICDISPLAY, 'topicdisplay', $topicdisplay));
66
    //Select image position
67
    $posselect = new \XoopsFormSelect(_AM_TOPICALIGN, 'topicalign', $topicalign);
68
    $posselect->addOption('R', _AM_RIGHT);
69
    $posselect->addOption('L', _AM_LEFT);
70
    $sform->addElement($posselect);
71
    //Publish in home?
72
    //TODO: Check that pubinhome is 0 = no and 1 = yes (currently vice versa)
73
    $sform->addElement(new \XoopsFormRadioYN(_AM_PUBINHOME, 'ihome', $ihome, _NO, _YES));
74
}
75
76
// News author
77
78
if ($approveprivilege && is_object($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) {
79
    if (!isset($newsauthor)) {
80
        $newsauthor = $xoopsUser->getVar('uid');
81
    }
82
    /** @var \XoopsMemberHandler $memberHandler */
83
    $memberHandler = xoops_getHandler('member');
84
    $usercount     = $memberHandler->getUserCount();
85
    if ($usercount < $cfg['config_max_users_list']) {
86
        $sform->addElement(new \XoopsFormSelectUser(_NW_AUTHOR, 'author', true, $newsauthor), false);
87
    } else {
88
        $sform->addElement(new \XoopsFormText(_NW_AUTHOR_ID, 'author', 10, 10, $newsauthor), false);
89
    }
90
}
91
92
$editor = News\Utility::getWysiwygForm(_NW_THESCOOP, 'hometext', $hometext, 15, 60, 'hometext_hidden');
93
$sform->addElement($editor, true);
94
95
//Extra info
96
//If admin -> if submit privilege
97
98
if ($approveprivilege) {
99
    $editor2 = News\Utility::getWysiwygForm(_AM_EXTEXT, 'bodytext', $bodytext, 15, 60, 'bodytext_hidden');
100
    $sform->addElement($editor2, false);
101
102
    if (News\Utility::getModuleOption('tags') && \class_exists(\XoopsModules\Tag\FormTag::class) && xoops_isActiveModule('tag')) {
103
        $itemIdForTag = $storyid ?? 0;
104
        $sform->addElement(new \XoopsModules\Tag\FormTag('item_tag', 60, 255, $itemIdForTag, 0));
105
    }
106
107
    if (News\Utility::getModuleOption('metadata')) {
108
        $sform->addElement(new xoopsFormText(_NW_META_DESCRIPTION, 'description', 50, 255, $description), false);
109
        $sform->addElement(new xoopsFormText(_NW_META_KEYWORDS, 'keywords', 50, 255, $keywords), false);
110
    }
111
} elseif (News\Utility::getModuleOption('tags') && \class_exists(\XoopsModules\Tag\FormTag::class) && xoops_isActiveModule('tag')) {
112
    $itemIdForTag = $storyid ?? 0;
113
    $sform->addElement(new \XoopsModules\Tag\FormTag('item_tag', 60, 255, $itemIdForTag, 0));
114
}
115
116
// Manage upload(s)
117
$allowupload = false;
118
switch ($helper->getConfig('uploadgroups')) {
119
    case 1: //Submitters and Approvers
120
        $allowupload = true;
121
        break;
122
    case 2: //Approvers only
123
        $allowupload = $approveprivilege;
124
        break;
125
    case 3: //Upload Disabled
126
        $allowupload = false;
127
        break;
128
}
129
130
if ($allowupload) {
131
    if ('edit' === $op) {
132
        $sfiles   = new Files();
133
        $filesarr = [];
134
        $filesarr = $sfiles->getAllbyStory($storyid);
135
        if (count($filesarr) > 0) {
136
            $upl_tray     = new \XoopsFormElementTray(_AM_UPLOAD_ATTACHFILE, '<br>');
137
            $upl_checkbox = new \XoopsFormCheckBox('', 'delupload[]');
138
139
            foreach ($filesarr as $onefile) {
140
                $link = sprintf("<a href='%s/%s' target='_blank'>%s</a>\n", XOOPS_UPLOAD_URL, $onefile->getDownloadname('S'), $onefile->getFileRealName('S'));
141
                $upl_checkbox->addOption($onefile->getFileid(), $link);
142
            }
143
            $upl_tray->addElement($upl_checkbox, false);
144
            $dellabel = new \XoopsFormLabel(_AM_DELETE_SELFILES, '');
145
            $upl_tray->addElement($dellabel, false);
146
            $sform->addElement($upl_tray);
147
        }
148
    }
149
    $sform->addElement(new \XoopsFormFile(_AM_SELFILE, 'attachedfile', $helper->getConfig('maxuploadsize')), false);
150
    if ('edit' === $op) {
151
        if (isset($picture) && '' !== xoops_trim($picture)) {
152
            $pictureTray = new \XoopsFormElementTray(_NW_CURENT_PICTURE, '<br>');
153
            $pictureTray->addElement(new \XoopsFormLabel('', "<img src='" . XOOPS_URL . '/uploads/news/image/' . $picture . "'>"));
154
            $deletePicureCheckbox = new \XoopsFormCheckBox('', 'deleteimage', 0);
155
            $deletePicureCheckbox->addOption(1, _DELETE);
156
            $pictureTray->addElement($deletePicureCheckbox);
157
            $sform->addElement($pictureTray);
158
        }
159
    }
160
    if (!isset($pictureinfo)) {
161
        $pictureinfo = '';
162
    }
163
    $sform->addElement(new \XoopsFormFile(_NW_SELECT_IMAGE, 'attachedimage', $helper->getConfig('maxuploadsize')), false);
164
    $sform->addElement(new \XoopsFormText(_NW_SELECT_IMAGE_DESC, 'pictureinfo', 50, 255, $pictureinfo), false);
165
}
166
167
$option_tray = new \XoopsFormElementTray(_OPTIONS, '<br>');
168
//Set date of publish/expiration
169
if ($approveprivilege) {
170
    $approve_checkbox = new \XoopsFormCheckBox('', 'approve', $approve);
171
    $approve_checkbox->addOption(1, _AM_APPROVE);
172
    $option_tray->addElement($approve_checkbox);
173
174
    $check              = $published > 0 ? 1 : 0;
175
    $published_checkbox = new \XoopsFormCheckBox('', 'autodate', $check);
176
    $published_checkbox->addOption(1, _AM_SETDATETIME);
177
    $option_tray->addElement($published_checkbox);
178
179
    $option_tray->addElement(new \XoopsFormDateTime(_AM_SETDATETIME, 'publish_date', 15, $published));
180
181
    $check            = $expired > 0 ? 1 : 0;
182
    $expired_checkbox = new \XoopsFormCheckBox('', 'autoexpdate', $check);
183
    $expired_checkbox->addOption(1, _AM_SETEXPDATETIME);
184
    $option_tray->addElement($expired_checkbox);
185
186
    $option_tray->addElement(new \XoopsFormDateTime(_AM_SETEXPDATETIME, 'expiry_date', 15, $expired));
187
}
188
189
if (is_object($xoopsUser)) {
190
    $notify_checkbox = new \XoopsFormCheckBox('', 'notifypub', $notifypub);
191
    $notify_checkbox->addOption(1, _NW_NOTIFYPUBLISH);
192
    $option_tray->addElement($notify_checkbox);
193
    if ($xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
194
        $nohtml_checkbox = new \XoopsFormCheckBox('', 'nohtml', $nohtml);
195
        $nohtml_checkbox->addOption(1, _DISABLEHTML);
196
        $option_tray->addElement($nohtml_checkbox);
197
    }
198
}
199
$smiley_checkbox = new \XoopsFormCheckBox('', 'nosmiley', $nosmiley);
200
$smiley_checkbox->addOption(1, _DISABLESMILEY);
201
$option_tray->addElement($smiley_checkbox);
202
203
$sform->addElement($option_tray);
204
205
//Submit buttons
206
$buttonTray  = new \XoopsFormElementTray('', '');
207
$preview_btn = new \XoopsFormButton('', 'preview', _PREVIEW, 'submit');
208
$preview_btn->setExtra('accesskey="p"');
209
$buttonTray->addElement($preview_btn);
210
$submit_btn = new \XoopsFormButton('', 'post', _NW_POST, 'submit');
211
$submit_btn->setExtra('accesskey="s"');
212
$buttonTray->addElement($submit_btn);
213
$sform->addElement($buttonTray);
214
215
//Hidden variables
216
if (isset($storyid)) {
217
    $sform->addElement(new \XoopsFormHidden('storyid', $storyid));
218
}
219
220
if (!isset($returnside)) {
221
    $returnside = Request::getInt('returnside', 0, 'POST');
222
    if (empty($returnside)) {
223
        $returnside = Request::getInt('returnside', 0, 'GET');
224
    }
225
}
226
227
if (!isset($returnside)) {
228
    $returnside = 0;
229
}
230
$sform->addElement(new \XoopsFormHidden('returnside', $returnside), false);
231
232
if (!isset($type)) {
233
    if ($approveprivilege) {
234
        $type = 'admin';
235
    } else {
236
        $type = 'user';
237
    }
238
}
239
$type_hidden = new \XoopsFormHidden('type', $type);
240
$sform->addElement($type_hidden);
241
242
echo '<h1>' . _NW_SUBMITNEWS . '</h1>';
243
if ('' !== xoops_trim(News\Utility::getModuleOption('submitintromsg'))) {
244
    echo "<div class='infotext'><br><br>" . nl2br(News\Utility::getModuleOption('submitintromsg')) . '<br><br></div>';
0 ignored issues
show
It seems like XoopsModules\News\Utilit...ption('submitintromsg') can also be of type boolean; however, parameter $string of nl2br() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

244
    echo "<div class='infotext'><br><br>" . nl2br(/** @scrutinizer ignore-type */ News\Utility::getModuleOption('submitintromsg')) . '<br><br></div>';
Loading history...
245
}
246
247
$sform->display();
248