Issues (381)

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.

admin/cat.php (2 issues)

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
2
/**
3
 * ****************************************************************************
4
 *  - A Project by Developers TEAM For Xoops - ( https://xoops.org )
5
 * ****************************************************************************
6
 *  XNEWSLETTER - MODULE FOR XOOPS
7
 *  Copyright (c) 2007 - 2012
8
 *  Goffy ( wedega.com )
9
 *
10
 *  You may not change or alter any portion of this comment or credits
11
 *  of supporting developers from this source code or any supporting
12
 *  source code which is considered copyrighted (c) material of the
13
 *  original comment or credit authors.
14
 *
15
 *  This program is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU General Public License for more details.
19
 *  ---------------------------------------------------------------------------
20
 * @copyright  Goffy ( wedega.com )
21
 * @license    GPL 2.0
22
 * @package    xnewsletter
23
 * @author     Goffy ( [email protected] )
24
 *
25
 * ****************************************************************************
26
 */
27
28
use Xmf\Request;
29
use XoopsModules\Xnewsletter;
30
31
$currentFile = basename(__FILE__);
32
require_once __DIR__ . '/admin_header.php';
33
xoops_cp_header();
34
35
// set template
36
$templateMain = 'xnewsletter_admin_categories.tpl';
37
38
// We recovered the value of the argument op in the URL$
39
$op     = Request::getString('op', 'list');
40
$cat_id = Request::getInt('cat_id', 0);
41
42
$GLOBALS['xoopsTpl']->assign('use_mailinglist', $helper->getConfig('xn_use_mailinglist'));
43
$GLOBALS['xoopsTpl']->assign('xnewsletter_url', XNEWSLETTER_URL);
44
$GLOBALS['xoopsTpl']->assign('xnewsletter_icons_url', XNEWSLETTER_ICONS_URL);
45
46
switch ($op) {
47
    case 'list':
48
    default:
49
        $adminObject->displayNavigation($currentFile);
50
        $adminObject->addItemButton(_AM_XNEWSLETTER_NEWCAT, '?op=new_cat', 'add');
51
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left'));
52
53
        $start       = Request::getInt('start', 0);
54
        $limit       = $helper->getConfig('adminperpage');
55
        $catsCount   = $helper->getHandler('Cat')->getCount();
56
        $catCriteria = new \CriteriaCompo();
57
        $catCriteria->setSort('cat_id ASC, cat_name');
58
        $catCriteria->setOrder('ASC');
59
        $catCriteria->setStart($start);
60
        $catCriteria->setLimit($limit);
61
        $catAll = $helper->getHandler('Cat')->getAll($catCriteria);
62 View Code Duplication
        if ($catsCount > $limit) {
0 ignored issues
show
This code seems to be duplicated across 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...
63
            require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
64
            $pagenav = new \XoopsPageNav($catsCount, $limit, $start, 'start', 'op=list');
65
            $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
66
        }
67
68
        if ($catsCount > 0) {
69
            $GLOBALS['xoopsTpl']->assign('categories_count', $catsCount);
70
            $groupNames = $memberHandler->getGroupList();
71
            /** @var \XoopsGroupPermHandler $grouppermHandler */
72
            $grouppermHandler = xoops_getHandler('groupperm');
73
            foreach (array_keys($catAll) as $i) {
74
                $cat    = $catAll[$i]->getValuesCat();
75
                $cat_id = $cat['id'];
76
                
77
                // cat_gperms_admin
78
                $cat_gperms_admin_groupids = $grouppermHandler->getGroupIds('newsletter_admin_cat', $cat_id, $helper->getModule()->mid());
79
                sort($cat_gperms_admin_groupids);
80
                $cat_gperms_admin = '';
81
                foreach ($cat_gperms_admin_groupids as $groupid) {
82
                    $cat_gperms_admin .= $groupNames[$groupid] . ' | ';
83
                }
84
                $cat_gperms_admin = mb_substr($cat_gperms_admin, 0, -3);
85
                $cat['gperms_admin'] = $cat_gperms_admin;
86
                // cat_gperms_create
87
                $cat_gperms_create_groupids = $grouppermHandler->getGroupIds('newsletter_create_cat', $cat_id, $helper->getModule()->mid());
88
                sort($cat_gperms_create_groupids);
89
                $cat_gperms_create = '';
90
                foreach ($cat_gperms_create_groupids as $groupid) {
91
                    $cat_gperms_create .= $groupNames[$groupid] . ' | ';
92
                }
93
                $cat_gperms_create = mb_substr($cat_gperms_create, 0, -3);
94
                $cat['gperms_create'] = $cat_gperms_create;
95
                // cat_gperms_list
96
                $cat_gperms_list_groupids = $grouppermHandler->getGroupIds('newsletter_list_cat', $cat_id, $helper->getModule()->mid());
97
                sort($cat_gperms_list_groupids);
98
                $cat_gperms_list = '';
99
                foreach ($cat_gperms_list_groupids as $groupid) {
100
                    $cat_gperms_list .= $groupNames[$groupid] . ' | ';
101
                }
102
                $cat_gperms_list = mb_substr($cat_gperms_list, 0, -3);
103
                $cat['gperms_list'] = $cat_gperms_list;
104
105
                // cat_gperms_read
106
                $cat_gperms_read_groupids = $grouppermHandler->getGroupIds('newsletter_read_cat', $cat_id, $helper->getModule()->mid());
107
                sort($cat_gperms_read_groupids);
108
                $cat_gperms_read = '';
109
                foreach ($cat_gperms_read_groupids as $groupid) {
110
                    $cat_gperms_read .= $groupNames[$groupid] . ' | ';
111
                }
112
                $cat_gperms_read = mb_substr($cat_gperms_read, 0, -3);
113
                $cat['gperms_read'] = $cat_gperms_read;
114
115
                $GLOBALS['xoopsTpl']->append('categories_list', $cat);
116
                unset($cat);
117
            }
118
        } else {
119
            $GLOBALS['xoopsTpl']->assign('error', _AM_XNEWSLETTER_THEREARENT_CAT);
120
        }
121
        break;
122
    case 'new_cat':
123
        $adminObject->displayNavigation($currentFile);
124
        $adminObject->addItemButton(_AM_XNEWSLETTER_CATLIST, '?op=list', 'list');
125
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left'));
126
127
        $catObj = $helper->getHandler('Cat')->create();
128
        $form   = $catObj->getForm();
129
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
130
        break;
131
    case 'save_cat':
132
        if (!$GLOBALS['xoopsSecurity']->check()) {
133
            redirect_header($currentFile, 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
134
        }
135
        $catObj = $helper->getHandler('Cat')->get($cat_id);
136
        $catObj->setVar('cat_name',        Request::getString('cat_name', ''));
137
        $catObj->setVar('cat_info',        Request::getString('cat_info', ''));
138
        $catObj->setVar('cat_mailinglist', Request::getInt('cat_mailinglist', 0));
139
        $catObj->setVar('cat_submitter',   $xoopsUser->uid());
140
        $catObj->setVar('cat_created',     time());
141
        $catObj->setVar('dohtml',          Request::getInt('dohtml', 0));
142
        $catObj->setVar('dosmiley',        Request::getInt('dosmiley', 0));
143
        $catObj->setVar('doxcode',         Request::getInt('doxcode', 0));
144
        $catObj->setVar('doimage',         Request::getInt('doimage', 0));
145
        $catObj->setVar('dobr',            Request::getInt('dobr', 0));
146
147
        if ($helper->getHandler('Cat')->insert($catObj)) {
148
            $cat_id = $catObj->getVar('cat_id');
149
            //
150
            // Form cat_gperms_read
151
            $grouppermHandler->deleteByModule($helper->getModule()->mid(), 'newsletter_read_cat', $cat_id);
152
            $grouppermHandler->addRight('newsletter_read_cat', $cat_id, XOOPS_GROUP_ADMIN, $helper->getModule()->mid());
153
            $cat_gperms_read_groupids = Request::getArray('cat_gperms_read', []);
154
            foreach ($cat_gperms_read_groupids as $groupid) {
155
                $grouppermHandler->addRight('newsletter_read_cat', $cat_id, $groupid, $helper->getModule()->mid());
156
            }
157
            // Form cat_gperms_admin
158
            $grouppermHandler->deleteByModule($helper->getModule()->mid(), 'newsletter_admin_cat', $cat_id);
159
            $grouppermHandler->addRight('newsletter_admin_cat', $cat_id, XOOPS_GROUP_ADMIN, $helper->getModule()->mid());
160
            $cat_gperms_admin_groupids = Request::getArray('cat_gperms_admin', []);
161
            foreach ($cat_gperms_admin_groupids as $groupid) {
162
                $grouppermHandler->addRight('newsletter_admin_cat', $cat_id, $groupid, $helper->getModule()->mid());
163
            }
164
            // Form cat_gperms_create
165
            $grouppermHandler->deleteByModule($helper->getModule()->mid(), 'newsletter_create_cat', $cat_id);
166
            $grouppermHandler->addRight('newsletter_create_cat', $cat_id, XOOPS_GROUP_ADMIN, $helper->getModule()->mid());
167
            $cat_gperms_create_groupids = Request::getArray('cat_gperms_create', []);
168
            foreach ($cat_gperms_create_groupids as $groupid) {
169
                $grouppermHandler->addRight('newsletter_create_cat', $cat_id, $groupid, $helper->getModule()->mid());
170
            }
171
            // Form cat_gperms_list
172
            $grouppermHandler->deleteByModule($helper->getModule()->mid(), 'newsletter_list_cat', $cat_id);
173
            $grouppermHandler->addRight('newsletter_list_cat', $cat_id, XOOPS_GROUP_ADMIN, $helper->getModule()->mid());
174
            $cat_gperms_list_groupids = Request::getArray('cat_gperms_list', []);
175
            foreach ($cat_gperms_list_groupids as $groupid) {
176
                $grouppermHandler->addRight('newsletter_list_cat', $cat_id, $groupid, $helper->getModule()->mid());
177
            }
178
179
            redirect_header('?op=list', 3, _AM_XNEWSLETTER_FORMOK);
180
        }
181
182
        $GLOBALS['xoopsTpl']->assign('error', $catObj->getHtmlErrors());
183
        $form = $catObj->getForm();
184
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
185
        break;
186 View Code Duplication
    case 'edit_cat':
0 ignored issues
show
This code seems to be duplicated across 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...
187
        $adminObject->displayNavigation($currentFile);
188
        $adminObject->addItemButton(_AM_XNEWSLETTER_NEWCAT, '?op=new_cat', 'add');
189
        $adminObject->addItemButton(_AM_XNEWSLETTER_CATLIST, '?op=list', 'list');
190
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left'));
191
192
        $catObj = $helper->getHandler('Cat')->get($cat_id);
193
        $form   = $catObj->getForm();
194
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
195
        break;
196
    case 'delete_cat':
197
        $catObj = $helper->getHandler('Cat')->get($_REQUEST['cat_id']);
198
        // check whether there are existing sbuscription to this cat
199
        if ($helper->getHandler('Catsubscr')->getCount(new \Criteria('catsubscr_catid', $cat_id)) > 0) {
200
            redirect_header($currentFile, 5, _AM_XNEWSLETTER_CAT_DELETE_ERROR);
201
        }
202
        
203
        if (true === Request::getBool('ok', false, 'POST')) {
204
            if (!$GLOBALS['xoopsSecurity']->check()) {
205
                redirect_header($currentFile, 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
206
            }
207
            if ($helper->getHandler('Cat')->delete($catObj)) {
208
                redirect_header($currentFile, 3, _AM_XNEWSLETTER_FORMDELOK);
209
            } else {
210
                $GLOBALS['xoopsTpl']->assign('error', $catObj->getHtmlErrors());
211
            }
212
        } else {
213
            xoops_confirm(['ok' => true, 'cat_id' => $cat_id, 'op' => 'delete_cat'], $_SERVER['REQUEST_URI'], sprintf(_AM_XNEWSLETTER_FORMSUREDEL, $catObj->getVar('cat_name')));
214
        }
215
        break;
216
}
217
require_once __DIR__ . '/admin_footer.php';
218