Issues (311)

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.

textblock.php (3 issues)

Labels
Severity
1
<?php declare(strict_types=1);
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
 * wgEvents module for xoops
15
 *
16
 * @copyright    2021 XOOPS Project (https://xoops.org)
17
 * @license      GPL 2.0 or later
18
 * @package      wgevents
19
 * @author       Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com
20
 */
21
22
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...
23
use XoopsModules\Wgevents;
24
use XoopsModules\Wgevents\Constants;
25
use XoopsModules\Wgevents\Common;
26
27
require __DIR__ . '/header.php';
28
$GLOBALS['xoopsOption']['template_main'] = 'wgevents_textblock.tpl';
29
require_once \XOOPS_ROOT_PATH . '/header.php';
30
31
$op    = Request::getCmd('op', 'list');
32
$tbId  = Request::getInt('id');
33
$start = Request::getInt('start');
34
$limit = Request::getInt('limit', $helper->getConfig('userpager'));
35
$GLOBALS['xoopsTpl']->assign('start', $start);
36
$GLOBALS['xoopsTpl']->assign('limit', $limit);
37
38
// Define Stylesheet
39
$GLOBALS['xoTheme']->addStylesheet($style, null);
40
// Paths
41
$GLOBALS['xoopsTpl']->assign('xoops_icons32_url', \XOOPS_ICONS32_URL);
42
$GLOBALS['xoopsTpl']->assign('wgevents_url', \WGEVENTS_URL);
43
// Keywords
44
$keywords = [];
45
// Breadcrumbs
46
$xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_INDEX, 'link' => 'index.php'];
47
// Permission
48
$permSubmit = $permissionsHandler->getPermTextblocksSubmit();
49
$GLOBALS['xoopsTpl']->assign('permSubmit', $permSubmit);
50
$GLOBALS['xoopsTpl']->assign('showItem', $tbId > 0);
51
52
switch ($op) {
53
    case 'show':
54
    case 'list':
55
    default:
56
        // Breadcrumbs
57
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_TEXTBLOCKS_LIST];
58
        $crTextblock = new \CriteriaCompo();
59
        if ($tbId > 0) {
60
            $crTextblock->add(new \Criteria('id', $tbId));
61
        }
62
        $textblocksCount = $textblockHandler->getCount($crTextblock);
63
        $GLOBALS['xoopsTpl']->assign('textblocksCount', $textblocksCount);
64
        if (0 === $tbId) {
65
            $crTextblock->setStart($start);
66
            $crTextblock->setLimit($limit);
67
        }
68
        $textblocksAll = $textblockHandler->getAll($crTextblock);
69
        if ($textblocksCount > 0) {
70
            $textblocks = [];
71
            $tbName = '';
72
            // Get All Textblock
73
            foreach (\array_keys($textblocksAll) as $i) {
74
                $textblocks[$i] = $textblocksAll[$i]->getValuesTextblocks();
75
                $tbName = $textblocksAll[$i]->getVar('name');
76
                $keywords[$i] = $tbName;
77
                $permEdit = $permissionsHandler->getPermTextblocksEdit($textblocksAll[$i]->getVar('submitter'));
78
                $textblocks[$i]['permEdit'] = $permEdit;
79
            }
80
            $GLOBALS['xoopsTpl']->assign('textblocks', $textblocks);
81
            unset($textblocks);
82
            // Display Navigation
83
            if ($textblocksCount > $limit) {
84
                require_once \XOOPS_ROOT_PATH . '/class/pagenav.php';
85
                $pagenav = new \XoopsPageNav($textblocksCount, $limit, $start, 'start', 'op=list&limit=' . $limit);
86
                $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav());
87
            }
88
            $GLOBALS['xoopsTpl']->assign('table_type', $helper->getConfig('table_type'));
89
            $GLOBALS['xoopsTpl']->assign('panel_type', $helper->getConfig('panel_type'));
90
            $GLOBALS['xoopsTpl']->assign('divideby', $helper->getConfig('divideby'));
91
            $GLOBALS['xoopsTpl']->assign('numb_col', $helper->getConfig('numb_col'));
92
            if ('show' === $op && '' !== $tbName) {
93
                $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', \strip_tags($tbName . ' - ' . $GLOBALS['xoopsModule']->getVar('name')));
94
            }
95
        } else {
96
            $GLOBALS['xoopsTpl']->assign('error', \_MA_WGEVENTS_TEXTBLOCKS_THEREARENT);
97
            if ($permSubmit) {
98
                $GLOBALS['xoopsTpl']->assign('permSubmitFirst', true);
99
            }
100
        }
101
        break;
102
    case 'save':
103
        // Security Check
104
        if (!$GLOBALS['xoopsSecurity']->check()) {
105
            \redirect_header('textblock.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
106
        }
107
108
        if ($tbId > 0) {
109
            $textblockObj = $textblockHandler->get($tbId);
110
            // Check permissions
111
            if (!$permissionsHandler->getPermTextblocksEdit($textblockObj->getVar('submitter'))) {
112
                \redirect_header('textblock.php?op=list', 3, \_NOPERM);
113
            }
114
        } else {
115
            // Check permissions
116
            if (!$permissionsHandler->getPermTextblocksSubmit()) {
117
                \redirect_header('textblock.php?op=list', 3, \_NOPERM);
118
            }
119
            $textblockObj = $textblockHandler->create();
120
        }
121
        $textblockObj->setVar('name', Request::getString('name'));
122
        $textblockObj->setVar('text', Request::getText('text'));
123
        $textblockObj->setVar('weight', Request::getInt('weight'));
124
        $textblockDatecreatedObj = \DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('datecreated'));
125
        $textblockObj->setVar('datecreated', $textblockDatecreatedObj->getTimestamp());
126
        $textblockObj->setVar('submitter', Request::getInt('submitter'));
127
        // Insert Data
128
        if ($textblockHandler->insert($textblockObj)) {
129
            $grouppermHandler = \xoops_getHandler('groupperm');
130
            $mid = $GLOBALS['xoopsModule']->getVar('mid');
131
            // Permission to view_textblocks
132
            $grouppermHandler->deleteByModule($mid, 'wgevents_view_textblocks', $newTbId);
0 ignored issues
show
The method deleteByModule() does not exist on XoopsObjectHandler. Did you maybe mean delete()? ( Ignorable by Annotation )

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

132
            $grouppermHandler->/** @scrutinizer ignore-call */ 
133
                               deleteByModule($mid, 'wgevents_view_textblocks', $newTbId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
133
            if (isset($_POST['groups_view_textblocks'])) {
134
                foreach ($_POST['groups_view_textblocks'] as $onegroupId) {
135
                    $grouppermHandler->addRight('wgevents_view_textblocks', $newTbId, $onegroupId, $mid);
0 ignored issues
show
The method addRight() 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

135
                    $grouppermHandler->/** @scrutinizer ignore-call */ 
136
                                       addRight('wgevents_view_textblocks', $newTbId, $onegroupId, $mid);
Loading history...
136
                }
137
            }
138
            // Permission to submit_textblocks
139
            $grouppermHandler->deleteByModule($mid, 'wgevents_submit_textblocks', $newTbId);
140
            if (isset($_POST['groups_submit_textblocks'])) {
141
                foreach ($_POST['groups_submit_textblocks'] as $onegroupId) {
142
                    $grouppermHandler->addRight('wgevents_submit_textblocks', $newTbId, $onegroupId, $mid);
143
                }
144
            }
145
            // Permission to approve_textblocks
146
            $grouppermHandler->deleteByModule($mid, 'wgevents_approve_textblocks', $newTbId);
147
            if (isset($_POST['groups_approve_textblocks'])) {
148
                foreach ($_POST['groups_approve_textblocks'] as $onegroupId) {
149
                    $grouppermHandler->addRight('wgevents_approve_textblocks', $newTbId, $onegroupId, $mid);
150
                }
151
            }
152
            // redirect after insert
153
            \redirect_header('textblock.php?op=list&amp;start=' . $start . '&amp;limit=' . $limit, 2, \_MA_WGEVENTS_FORM_OK);
154
        }
155
        // Get Form Error
156
        $GLOBALS['xoopsTpl']->assign('error', $textblockObj->getHtmlErrors());
157
        $form = $textblockObj->getForm();
158
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
159
        break;
160
    case 'new':
161
        // Breadcrumbs
162
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_TEXTBLOCK_ADD];
163
        // Check permissions
164
        if (!$permissionsHandler->getPermTextblocksSubmit()) {
165
            \redirect_header('textblock.php?op=list', 3, \_NOPERM);
166
        }
167
        // Form Create
168
        $textblockObj = $textblockHandler->create();
169
        $form = $textblockObj->getForm();
170
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
171
        break;
172
    case 'edit':
173
        // Breadcrumbs
174
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_TEXTBLOCK_EDIT];
175
        // Check params
176
        if (0 === $tbId) {
177
            \redirect_header('textblock.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
178
        }
179
        // Get Form
180
        $textblockObj = $textblockHandler->get($tbId);
181
        // Check permissions
182
        if (!$permissionsHandler->getPermTextblocksEdit($textblockObj->getVar('submitter'))) {
183
            \redirect_header('textblock.php?op=list', 3, \_NOPERM);
184
        }
185
        $textblockObj->start = $start;
186
        $textblockObj->limit = $limit;
187
        $form = $textblockObj->getForm();
188
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
189
        break;
190
    case 'clone':
191
        // Breadcrumbs
192
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_TEXTBLOCK_CLONE];
193
        // Check permissions
194
        if (!$permissionsHandler->getPermGlobalSubmit()) {
195
            \redirect_header('textblock.php?op=list', 3, \_NOPERM);
196
        }
197
        // Request source
198
        $tbIdSource = Request::getInt('id_source');
199
        // Check params
200
        if (0 === $tbIdSource) {
201
            \redirect_header('textblock.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
202
        }
203
        // Get Form
204
        $textblockObjSource = $textblockHandler->get($tbIdSource);
205
        $textblockObj = $textblockObjSource->xoopsClone();
206
        $form = $textblockObj->getForm();
207
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
208
        break;
209
    case 'delete':
210
        // Breadcrumbs
211
        $xoBreadcrumbs[] = ['title' => \_MA_WGEVENTS_TEXTBLOCK_DELETE];
212
        // Check permissions
213
        if (!$permissionsHandler->getPermGlobalSubmit()) {
214
            \redirect_header('textblock.php?op=list', 3, \_NOPERM);
215
        }
216
        // Check params
217
        if (0 === $tbId) {
218
            \redirect_header('textblock.php?op=list', 3, \_MA_WGEVENTS_INVALID_PARAM);
219
        }
220
        $textblockObj = $textblockHandler->get($tbId);
221
        $tbName = $textblockObj->getVar('name');
222
        if (isset($_REQUEST['ok']) && 1 === (int)$_REQUEST['ok']) {
223
            if (!$GLOBALS['xoopsSecurity']->check()) {
224
                \redirect_header('textblock.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
225
            }
226
            if ($textblockHandler->delete($textblockObj)) {
227
                \redirect_header('textblock.php', 3, \_MA_WGEVENTS_FORM_DELETE_OK);
228
            } else {
229
                $GLOBALS['xoopsTpl']->assign('error', $textblockObj->getHtmlErrors());
230
            }
231
        } else {
232
            $customConfirm = new Common\Confirm(
233
                ['ok' => 1, 'id' => $tbId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'],
234
                $_SERVER['REQUEST_URI'],
235
                \sprintf(\_MA_WGEVENTS_CONFIRMDELETE_TEXTBLOCK, $textblockObj->getVar('name')), \_MA_WGEVENTS_CONFIRMDELETE_TITLE, \_MA_WGEVENTS_CONFIRMDELETE_LABEL);
236
            $form = $customConfirm->getFormConfirm();
237
            $GLOBALS['xoopsTpl']->assign('form', $form->render());
238
        }
239
        break;
240
}
241
242
// Keywords
243
wgeventsMetaKeywords($helper->getConfig('keywords') . ', ' . \implode(',', $keywords));
244
unset($keywords);
245
246
// Description
247
wgeventsMetaDescription(\_MA_WGEVENTS_TEXTBLOCKS_DESC);
248
$GLOBALS['xoopsTpl']->assign('xoops_mpageurl', \WGEVENTS_URL.'/textblock.php');
249
$GLOBALS['xoopsTpl']->assign('wgevents_upload_url', \WGEVENTS_UPLOAD_URL);
250
251
require __DIR__ . '/footer.php';
252