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/subscr.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
 *  Version : 1 Wed 2012/11/28 22:18:22 :  Exp $
26
 * ****************************************************************************
27
 */
28
29
use Xmf\Request;
30
31
$currentFile = basename(__FILE__);
32
require_once __DIR__ . '/admin_header.php';
33
xoops_cp_header();
34
35
// set template
36
$templateMain = 'xnewsletter_admin_subscribers.tpl';
37
38
// We recovered the value of the argument op in the URL$
39
$op       = Request::getString('op', 'list');
40
$subscrId = Request::getInt('subscr_id', 0);
41
42
$filter_subscr           = Request::getString('filter_subscr', '=');
43
$filter_subscr_firstname = Request::getString('filter_subscr_firstname', '');
44
$filter_subscr_lastname  = Request::getString('filter_subscr_lastname', '');
45
$filter_subscr_email     = Request::getString('filter_subscr_email', '');
46
47
if ('apply_filter' === $op) {
48
    if ('LIKE' === $filter_subscr && '' == !$filter_subscr_firstname) {
49
        $filter_subscr_firstname = "%{$filter_subscr_firstname}%";
50
    }
51
    if ('LIKE' === $filter_subscr && '' == !$filter_subscr_lastname) {
52
        $filter_subscr_lastname = "%{$filter_subscr_lastname}%";
53
    }
54
    if ('LIKE' === $filter_subscr && '' == !$filter_subscr_email) {
55
        $filter_subscr_email = "%{$filter_subscr_email}%";
56
    }
57
    if ('' == $filter_subscr_firstname && '' == $filter_subscr_lastname && '' == $filter_subscr_email) {
58
        $op = 'list';
59
    }
60
}
61
62
$GLOBALS['xoopsTpl']->assign('xnewsletter_url', XNEWSLETTER_URL);
63
$GLOBALS['xoopsTpl']->assign('xnewsletter_icons_url', XNEWSLETTER_ICONS_URL);
64
$GLOBALS['xoopsTpl']->assign('op', $op);
65
$GLOBALS['xoopsTpl']->assign('filter_subscr', $filter_subscr);
66
$GLOBALS['xoopsTpl']->assign('filter_subscr_firstname', $filter_subscr_firstname);
67
$GLOBALS['xoopsTpl']->assign('filter_subscr_lastname', $filter_subscr_lastname);
68
$GLOBALS['xoopsTpl']->assign('filter_subscr_email', $filter_subscr_email);
69
70
71
switch ($op) {
72
    case 'show_catsubscr':
73
        $adminObject->displayNavigation($currentFile);
74
        $apply_filter = Request::getString('apply_filter', 'list');
75
        $linklist     = "?op=$apply_filter&filter_subscr={$filter_subscr}";
76
        $linklist     .= "&filter_subscr_firstname={$filter_subscr_firstname}";
77
        $linklist     .= "&filter_subscr_lastname={$filter_subscr_lastname}";
78
        $linklist     .= "&filter_subscr_email={$filter_subscr_email}";
79
        $adminObject->addItemButton(_AM_XNEWSLETTER_SUBSCR_SHOW_ALL, $linklist, 'view_detailed');
80
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left'));
81
82
        $subscrObj = $helper->getHandler('Subscr')->get($subscrId);
83
        $show_catsubscr['id'] = $subscrObj->getVar('subscr_id');
84
        $show_catsubscr['email'] = $subscrObj->getVar('subscr_email');
85
        
86
        $cats = '';
87
        $catsubscrCriteria = new \CriteriaCompo();
88
        $catsubscrCriteria->add(new \Criteria('catsubscr_subscrid', $subscrId));
89
        $catsubscrCount = $helper->getHandler('Catsubscr')->getCount($catsubscrCriteria);
90
        if ($catsubscrCount > 0) {
91
            $catsubscrObjs = $helper->getHandler('Catsubscr')->getAll($catsubscrCriteria);
92
            foreach ($catsubscrObjs as $catsubscr_id => $catsubscrObj) {
93
                $cat_id = $catsubscrObj->getVar('catsubscr_catid');
94
                $catObj = $helper->getHandler('Cat')->get($cat_id);
95
                if (is_object($catObj)) {
96
                    $cats .= $catObj->getVar('cat_name') . '<br>';
97
                } else {
98
                    $cats .= "INVALID CATEGORY - ID: $cat_id<br>";
99
                }
100
            }
101
        } else {
102
            $cats .= _AM_XNEWSLETTER_SUBSCR_NO_CATSUBSCR;
103
        }
104
        $show_catsubscr['cats'] = $cats;
105
        
106
        $GLOBALS['xoopsTpl']->assign('show_catsubscr', $show_catsubscr);
107
        break;
108
    case 'list':
109
    case 'apply_filter':
110
    default:
111
        $start = Request::getInt('start', 0);
112
        $limit = $helper->getConfig('adminperpage');
113
        $GLOBALS['xoopsTpl']->assign('start', $start);
114
        $GLOBALS['xoopsTpl']->assign('limit', $limit);
115
        
116
        $adminObject->displayNavigation($currentFile);
117
        $adminObject->addItemButton(_AM_XNEWSLETTER_NEWSUBSCR, '?op=new_subscr', 'add');
118
        if ('apply_filter' === $op) {
119
            $adminObject->addItemButton(_AM_XNEWSLETTER_SUBSCR_SHOW_ALL, '?op=list', 'view_detailed');
120
        }
121
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left'));
122
123
        $subscrCriteria = new \CriteriaCompo();
124
        if ('apply_filter' === $op) {
125
            if ('' != $filter_subscr_firstname) {
126
                $subscrCriteria->add(new \Criteria('subscr_firstname', $filter_subscr_firstname, $filter_subscr));
127
            }
128
            if ('' != $filter_subscr_lastname) {
129
                $subscrCriteria->add(new \Criteria('subscr_lastname', $filter_subscr_lastname, $filter_subscr));
130
            }
131
            if ('' != $filter_subscr_email) {
132
                $subscrCriteria->add(new \Criteria('subscr_email', $filter_subscr_email, $filter_subscr));
133
            }
134
        }
135
        $subscrCriteria->setSort('subscr_id');
136
        $subscrCriteria->setOrder('DESC');
137
        $subscrCount = $helper->getHandler('Subscr')->getCount($subscrCriteria);
138
        
139
        $subscrCriteria->setStart($start);
140
        $subscrCriteria->setLimit($limit);
141
        $subscrAll = $helper->getHandler('Subscr')->getAll($subscrCriteria);
142
        if ($subscrCount > $limit) {
143
            require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
144
            $linklist = "op={$op}";
145
            $linklist .= "&filter_subscr={$filter_subscr}";
146
            $linklist .= "&filter_subscr_firstname={$filter_subscr_firstname}";
147
            $linklist .= "&filter_subscr_lastname={$filter_subscr_lastname}";
148
            $linklist .= "&filter_subscr_email={$filter_subscr_email}";
149
            $pagenav  = new \XoopsPageNav($subscrCount, $limit, $start, 'start', $linklist);
150
            $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
151
        }
152
        if ('LIKE' === $filter_subscr) {
153
            //clean up var for refill form
154
            $filter_subscr_firstname = str_replace('%', '', $filter_subscr_firstname);
155
            $filter_subscr_lastname  = str_replace('%', '', $filter_subscr_lastname);
156
            $filter_subscr_email     = str_replace('%', '', $filter_subscr_email);
157
        }
158
159
        if ($subscrCount > 0) {
160
            $GLOBALS['xoopsTpl']->assign('subscribers_count', $subscrCount);
161
            
162
            $form_filter = "<form id='form_filter' enctype='multipart/form-data' method='post' action='{$currentFile}' name='form_filter'>";
163
            $form_filter .= "<tr class='odd'>";
164
            $form_filter .= "    <td class='center'>&nbsp;</td>";
165
            $form_filter .= "    <td colspan='2'>" . _SEARCH . ':&nbsp;&nbsp;';
166
            $form_filter .= "    <select id='filter_subscr' title='" . _SEARCH . "' name='filter_subscr' size='1'>";
167
            $form_filter .= "        <option value='='" . (('=' === $filter_subscr) ? ' selected' : '') . '>' . _AM_XNEWSLETTER_SEARCH_EQUAL . '</option>';
168
            $form_filter .= "        <option value='LIKE'" . (('LIKE' === $filter_subscr) ? ' selected' : '') . '>' . _AM_XNEWSLETTER_SEARCH_CONTAINS . '</option>';
169
            $form_filter .= '    </select>';
170
            $form_filter .= '    </td>';
171
            $form_filter .= "    <td><input id='filter_subscr_firstname' type='text' value='{$filter_subscr_firstname}' maxlength='50' size='15' title='' name='filter_subscr_firstname'></td>";
172
            $form_filter .= "    <td><input id='filter_subscr_lastname' type='text' value='{$filter_subscr_lastname}' maxlength='50' size='15' title='' name='filter_subscr_lastname'></td>";
173
            $form_filter .= "    <td><input id='filter_subscr_email' type='text' value='{$filter_subscr_email}' maxlength='255' size='40' title='' name='filter_subscr_email'></td>";
174
            $form_filter .= '    <td>&nbsp;</td>';
175
            $form_filter .= '    <td>&nbsp;</td>';
176
            $form_filter .= "    <td class='center'><input id='filter_submit' class='formButton' type='submit' title='" . _SEARCH . "' value='" . _SEARCH . "' name='filter_submit'></td>";
177
            $form_filter .= '</tr>';
178
            $form_filter .= "<input id='filter_op' type='hidden' value='apply_filter' name='op'>";
179
            $form_filter .= '</form>';
180
            $GLOBALS['xoopsTpl']->assign('form_filter', $form_filter);
181
            
182
            foreach ($subscrAll as $subscr_id => $subscrObj) {
183
                $subscr = $subscrObj->getValuesSubscr();
184
                $subscr['username'] = '-';
185
                if ($subscrObj->getVar('subscr_uid') > 0) {
186
                    $subscr['username'] = \XoopsUser::getUnameFromId($subscrObj->getVar('subscr_uid'), 'S');
187
                }
188
                if (0 == $subscrObj->getVar('subscr_activated')) {
189
                    $subscr['activated_img'] = '<img src="' . XNEWSLETTER_ICONS_URL . '/xn_failed.png" alt="' . _AM_XNEWSLETTER_SUBSCRWAIT . '" title="' . _AM_XNEWSLETTER_SUBSCRWAIT . '"> ';
190
                } else {
191
                    $subscr['activated_img'] = '<img src="' . XNEWSLETTER_ICONS_URL . '/xn_ok.png" alt="' . _MA_XNEWSLETTER_SUBSCRIPTION_REG_CLOSED . '" title="' . _MA_XNEWSLETTER_SUBSCRIPTION_REG_CLOSED . '"> ';
192
                }
193
                $subscr['created_ip'] = formatTimestamp($subscrObj->getVar('subscr_created'), $helper->getConfig('dateformat')) . ' [' . $subscrObj->getVar('subscr_ip') . ']';
194
195
                $GLOBALS['xoopsTpl']->append('subscribers_list', $subscr);
196
                unset($subscr);
197
            }
198
        } else {
199
            $GLOBALS['xoopsTpl']->assign('error', _AM_XNEWSLETTER_THEREARENT_SUBSCR);
200
        }
201
        break;
202
    case 'apply_actions':
203
        $action         = Request::getString('actions_action');
204
        $subscr_ids     = Request::getArray('subscr_ids', unserialize(Request::getString('serialize_subscr_ids')));
205
        $subscrCriteria = new \Criteria('subscr_id', '(' . implode(',', $subscr_ids) . ')', 'IN');
206
        switch ($action) {
207
            case 'delete':
208
                if (true === Request::getBool('ok', false, 'POST')) {
209
                    // delete subscriber (subscr), subscriptions (catsubscrs) and mailinglist
210
                    if ($helper->getHandler('Subscr')->deleteAll($subscrCriteria)) {
211
                        redirect_header($currentFile, 3, _AM_XNEWSLETTER_FORMDELOK);
212
                    } else {
213
                        $GLOBALS['xoopsTpl']->assign('error', $subscrObj->getHtmlErrors());
214
                    }
215
                } else {
216
                    $subscr_emails = [];
217
                    foreach ($helper->getHandler('Subscr')->getObjects($subscrCriteria) as $subscrObj) {
218
                        $subscr_emails[] = $subscrObj->getVar('subscr_email');
219
                    }
220
                    xoops_confirm([
221
                                      'ok'                   => true,
222
                                      'op'                   => 'apply_actions',
223
                                      'actions_action'       => $action,
224
                                      'serialize_subscr_ids' => serialize($subscr_ids),
225
                                  ], $_SERVER['REQUEST_URI'], sprintf(_AM_XNEWSLETTER_FORMSUREDEL, implode(', ', $subscr_emails)));
226
                }
227
                break;
228 View Code Duplication
            case 'activate':
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...
229
                // activate subscriber (subscr)
230
                if ($helper->getHandler('Subscr')->updateAll('subscr_activated', true, $subscrCriteria, true)) {
231
                    redirect_header($currentFile, 3, _AM_XNEWSLETTER_FORMACTIVATEOK);
232
                } else {
233
                    $GLOBALS['xoopsTpl']->assign('error', $subscrObj->getHtmlErrors());
234
                }
235
                break;
236 View Code Duplication
            case 'unactivate':
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...
237
                // unactivate subscriber (subscr)
238
                if ($helper->getHandler('Subscr')->updateAll('subscr_activated', 0, $subscrCriteria, true)) {
239
                    redirect_header($currentFile, 3, _AM_XNEWSLETTER_FORMUNACTIVATEOK);
240
                } else {
241
                    $GLOBALS['xoopsTpl']->assign('error', $subscrObj->getHtmlErrors());
242
                }
243
                break;
244
            default:
245
                // NOP
246
                break;
247
        }
248
        break;
249
    case 'new_subscr':
250
        $adminObject->displayNavigation($currentFile);
251
        $adminObject->addItemButton(_AM_XNEWSLETTER_SUBSCRLIST, '?op=list', 'list');
252
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left'));
253
254
        $subscrObj = $helper->getHandler('Subscr')->create();
255
        $form      = $subscrObj->getFormAdmin();
256
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
257
        break;
258
    case 'save_subscr':
259
        if (!$GLOBALS['xoopsSecurity']->check()) {
260
            redirect_header($currentFile, 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
261
        }
262
        $start = Request::getInt('start', 0);
263
        
264
        $subscrObj = $helper->getHandler('Subscr')->get($subscrId);
265
        $subscrObj->setVar('subscr_email',     Request::getString('subscr_email', ''));
266
        $subscrObj->setVar('subscr_firstname', Request::getString('subscr_firstname', ''));
267
        $subscrObj->setVar('subscr_lastname',  Request::getString('subscr_lastname', ''));
268
        $subscrObj->setVar('subscr_uid',       Request::getInt('subscr_uid', 0));
269
        $subscrObj->setVar('subscr_sex',       Request::getString('subscr_sex', ''));
270
        $subscrObj->setVar('subscr_submitter', Request::getInt('subscr_submitter', 0));
271
        $subscrObj->setVar('subscr_created',   Request::getInt('subscr_created', 0));
272
        $subscrObj->setVar('subscr_ip',        Request::getString('subscr_ip', ''));
273
        $subscrActkey = Request::getString('subscr_actkey', '');
274
        if ('' === $subscrActkey) {
275
            $subscrActkey = xoops_makepass();
276
        }
277
        $subscrObj->setVar('subscr_actkey',    Request::getString('subscr_actkey', ''));
278
        $subscrObj->setVar('subscr_activated', Request::getInt('subscr_activated', 0));
279
280
        if ($helper->getHandler('Subscr')->insert($subscrObj)) {
281
            redirect_header('?op=list&amp;start=' . $start, 3, _AM_XNEWSLETTER_FORMOK);
282
        }
283
        $GLOBALS['xoopsTpl']->assign('error', $subscrObj->getHtmlErrors());
284
        $form = $subscrObj->getFormAdmin();
285
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
286
        break;
287
    case 'edit_subscr':
288
        $start = Request::getInt('start', 0);
289
        $adminObject->displayNavigation($currentFile);
290
        $adminObject->addItemButton(_AM_XNEWSLETTER_NEWSUBSCR, '?op=new_subscr', 'add');
291
        $adminObject->addItemButton(_AM_XNEWSLETTER_SUBSCRLIST, '?op=list', 'list');
292
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left'));
293
294
        $subscrObj = $helper->getHandler('Subscr')->get($subscrId);
295
        $subscrObj->setVar('start', $start);
296
        $form      = $subscrObj->getFormAdmin(false, true);
297
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
298
        break;
299
    case 'delete_subscr':
300
        $start = Request::getInt('start', 0);
301
        $GLOBALS['xoopsTpl']->assign('start', $start);
302
        $GLOBALS['xoopsTpl']->assign('limit', $limit);
303
        
304
        $subscrObj = $helper->getHandler('Subscr')->get($subscrId);
305
        if (true === Request::getBool('ok', false, 'POST')) {
306
            if (!$GLOBALS['xoopsSecurity']->check()) {
307
                redirect_header($currentFile, 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
308
            }
309
            // delete subscriber (subscr), subscriptions (catsubscrs) and mailinglist
310
            if ($helper->getHandler('Subscr')->delete($subscrObj)) {
311
                redirect_header($currentFile, 3, _AM_XNEWSLETTER_FORMDELOK);
312
            } else {
313
                $GLOBALS['xoopsTpl']->assign('error', $subscrObj->getHtmlErrors());
314
            }
315
        } else {
316
            xoops_confirm(['ok' => true, 'subscr_id' => $subscrId, 'op' => 'delete_subscr', 'start' => $start], $_SERVER['REQUEST_URI'], sprintf(_AM_XNEWSLETTER_FORMSUREDEL, $subscrObj->getVar('subscr_email')));
317
        }
318
        break;
319
}
320
require_once __DIR__ . '/admin_footer.php';
321