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/protocol.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
30
$currentFile = basename(__FILE__);
31
require_once __DIR__ . '/admin_header.php';
32
xoops_cp_header();
33
34
// set template
35
$templateMain = 'xnewsletter_admin_protocols.tpl';
36
37
// We recovered the value of the argument op in the URL$
38
$op = Request::getString('op', 'list');
39
40
$GLOBALS['xoopsTpl']->assign('xnewsletter_url', XNEWSLETTER_URL);
41
$GLOBALS['xoopsTpl']->assign('xnewsletter_icons_url', XNEWSLETTER_ICONS_URL);
42
43
switch ($op) {
44
    case 'list':
45
    case 'list_protocols':
46
        $GLOBALS['xoopsTpl']->assign('list_protocols', true);
47
        $adminObject->displayNavigation($currentFile);
48
        
49
        $limit = $helper->getConfig('adminperpage');
50
        $start = Request::getInt('start', 0);
51
52
        //first show misc protocol items
53
        $protocolCriteria = new \CriteriaCompo();
54
        $protocolCriteria->add(new \Criteria('protocol_letter_id', '0'));
55
        $protocolCriteria->setSort('protocol_id');
56
        $protocolCriteria->setOrder('DESC');
57
        $protocolCount = $helper->getHandler('Protocol')->getCount($protocolCriteria);
58
        $protocolCriteria->setLimit(2);
59
        $protocolsAll               = $helper->getHandler('Protocol')->getAll($protocolCriteria);
60
        $protocol_status            = '';
61
        $protocol_created           = '';
62
        $protocol_created_formatted = '';
63
        $p                          = 0;
64 View Code Duplication
        foreach ($protocolsAll as $id => $protocolObj) {
65
            ++$p;
66
            if (count($protocolsAll) > 1) {
67
                $protocol_status .= "($p) ";
68
            }
69
            $protocol_status            .= $protocolObj->getVar('protocol_status') . '<br>';
70
            $protocol_created_formatted .= formatTimestamp($protocolObj->getVar('protocol_created'), 'M') . '<br>';
71
        }
72
        if ($protocolCount > 2) {
73
            $protocol_status .= '...';
74
        }
75
        $GLOBALS['xoopsTpl']->assign('protocol_status', $protocol_status);
76
        $GLOBALS['xoopsTpl']->assign('protocol_created_formatted', $protocol_created_formatted);
77
78
//        letter details
79
80
        $sql = 'SELECT protocol_letter_id FROM ' . $xoopsDB->prefix('xnewsletter_protocol') . ' GROUP BY protocol_letter_id';
81
        $prot_letters = $xoopsDB->query($sql);
82
        $protocol_letters_total = $prot_letters->num_rows;
83
84
        $sql = 'SELECT protocol_letter_id FROM ' . $xoopsDB->prefix('xnewsletter_protocol') . ' GROUP BY protocol_letter_id LIMIT ' . $start.', ' . $limit;
85
        $prot_letters = $xoopsDB->query($sql);
86
87
        while (false !== ($prot_letter = $xoopsDB->fetchArray($prot_letters))) {
88
            $protocol_letter_id = $prot_letter['protocol_letter_id'];
89
            $letterCriteria = new \CriteriaCompo();
90
            $letterCriteria->add(new \Criteria('letter_id', $protocol_letter_id));
91
            $letterCount = $helper->getHandler('Letter')->getCount();
92
            $letterObjs = $helper->getHandler('Letter')->getAll($letterCriteria);
93
94
            if ($letterCount > 0) {
95
                $GLOBALS['xoopsTpl']->assign('letters_count', $letterCount);
96
                foreach (array_keys($letterObjs) as $i) {
97
                    $protocolCriteria = new \CriteriaCompo();
98
                    $protocolCriteria->add(new \Criteria('protocol_letter_id', $letterObjs[$i]->getVar('letter_id')));
99
                    $protocolCriteria->setSort('protocol_id');
100
                    $protocolCriteria->setOrder('DESC');
101
                    $protocolCount = $helper->getHandler('Protocol')->getCount($protocolCriteria);
102
                    if ($protocolCount > 0) {
103
                        $protocolCriteria->setLimit(2);
104
                        $protocolsAll     = $helper->getHandler('Protocol')->getAll($protocolCriteria);
105
                        $protocol_status  = '';
106
                        $protocol_created = '';
107
108
                        $protocol_item['letter_title'] = $letterObjs[$i]->getVar('letter_title');
109
110
                        $p = 0;
111 View Code Duplication
                        foreach ($protocolsAll as $protocol) {
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...
112
                            ++$p;
113
                            if (count($protocolsAll) > 1) {
114
                                $protocol_status .= "($p) ";
115
                            }
116
                            $protocol_status  .= $protocol->getVar('protocol_status') . '<br>';
117
                            $protocol_created .= formatTimestamp($protocol->getVar('protocol_created'), 'M') . '<br>';
118
                        }
119
                        if ($protocolCount > 2) {
120
                            $protocol_status .= '...';
121
                        }
122
                        $protocol_item['letter_id'] = $letterObjs[$i]->getVar('letter_id');
123
                        $protocol_item['status'] = $protocol_status;
124
                        $protocol_item['created'] = $protocol_created;
125
126
                        $GLOBALS['xoopsTpl']->append('protocols_list', $protocol_item);
127
                        unset($protocol);
128
                    }
129
                }
130
            }
131
        }
132 View Code Duplication
        if ($protocol_letters_total > $limit) {
133
            require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
134
            $pagenav = new \XoopsPageNav($protocol_letters_total, $limit, $start, 'start', 'op=list');
135
            $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
136
        }
137
        break;
138
    case 'list_letter':
139
        $GLOBALS['xoopsTpl']->assign('list_letter', true);
140
        $letter_id = isset($_REQUEST['letter_id']) ? $_REQUEST['letter_id'] : '0';
141
        $adminObject->displayNavigation($currentFile);
142
        $adminObject->addItemButton(_AM_XNEWSLETTER_PROTOCOLLIST, '?op=list', 'list');
143
144
        $adminObject->addItemButton(_AM_XNEWSLETTER_LETTER_DELETE_ALL, '?op=delete_protocol_list&letter_id=' . $letter_id, 'delete');
145
        
146
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left'));
147
        $limit = $helper->getConfig('adminperpage');
148
149
        $protocolCriteria = new \CriteriaCompo();
150
        $protocolCriteria->add(new \Criteria('protocol_letter_id', $letter_id));
151
        $protocolCriteria->setSort('protocol_id');
152
        $protocolCriteria->setOrder('DESC');
153
        $protocolCount = $helper->getHandler('Protocol')->getCount($protocolCriteria);
154
        $start         = Request::getInt('start', 0);
155
        $protocolCriteria->setStart($start);
156
        $protocolCriteria->setLimit($limit);
157
        $protocolsAll = $helper->getHandler('Protocol')->getAll($protocolCriteria);
158 View Code Duplication
        if ($protocolCount > $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...
159
            require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
160
            $pagenav = new \XoopsPageNav($protocolCount, $limit, $start, 'start', 'op=list_letter&letter_id=' . $letter_id);
161
            $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
162
        }
163
164
        // View Table
165
        $letterObj = $helper->getHandler('Letter')->get($letter_id);
166
        $GLOBALS['xoopsTpl']->assign('letter_title', $letterObj->getVar('letter_title'));
167
        if ($protocolCount > 0) {
168
            $GLOBALS['xoopsTpl']->assign('protocols_count', $protocolCount);
169
            $class = 'odd';
170
            foreach ($protocolsAll as $id => $protocolObj) {
171
                $protocol = $protocolObj->getValuesProtocol();
172
                $subscrObj  = $helper->getHandler('Subscr')->get($protocolObj->getVar('protocol_subscriber_id'));
173
                $subscriber = $subscrObj ? $subscrObj->getVar('subscr_email') : _AM_XNEWSLETTER_PROTOCOL_NO_SUBSCREMAIL;
174
                if ('' == $subscriber) {
175
                    $subscriber = '-';
176
                }
177
                $protocol['subscriber'] = $subscriber;
178
                $success_text = (true === (bool)$protocolObj->getVar('protocol_success')) ? XNEWSLETTER_IMG_OK : XNEWSLETTER_IMG_FAILED;
179
                $protocol['success_text'] = $success_text;
180
                $GLOBALS['xoopsTpl']->append('protocols_list2', $protocol);
181
                unset($protocol);
182
            }
183
        }
184
        break;
185
    case 'new_protocol':
186
        $adminObject->displayNavigation($currentFile);
187
        $adminObject->addItemButton(_AM_XNEWSLETTER_PROTOCOLLIST, '?op=list', 'list');
188
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left'));
189
190
        $protocolObj = $helper->getHandler('Protocol')->create();
191
        $form        = $protocolObj->getForm();
192
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
193
        break;
194
    case 'save_protocol':
195
        if (!$GLOBALS['xoopsSecurity']->check()) {
196
            redirect_header($currentFile, 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
197
        }
198 View Code Duplication
        if (Request::hasVar('protocol_id', 'REQUEST')) {
199
            $protocolObj = $helper->getHandler('Protocol')->get(Request::getInt('protocol_id', 0));
200
        } else {
201
            $protocolObj = $helper->getHandler('Protocol')->create();
202
        }
203
204
        $protocolObj->setVar('protocol_letter_id',     Request::getInt('protocol_letter_id', 0));
205
        $protocolObj->setVar('protocol_subscriber_id', Request::getInt('protocol_subscriber_id', 0));
206
        $protocolObj->setVar('protocol_status',        Request::getString('protocol_status', ''));
207
        $protocolObj->setVar('protocol_success',       Request::getString('protocol_success', ''));
208
        $protocolObj->setVar('protocol_submitter',     Request::getInt('protocol_submitter', 0));
209
        $protocolObj->setVar('protocol_created', strtotime(Request::getInt('protocol_created', 0)));
210
211
        if ($helper->getHandler('Protocol')->insert($protocolObj)) {
212
            redirect_header('?op=list', 3, _AM_XNEWSLETTER_FORMOK);
213
        }
214
215
        $GLOBALS['xoopsTpl']->assign('error', $protocolObj->getHtmlErrors());
216
        $form = $protocolObj->getForm();
217
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
218
        break;
219 View Code Duplication
    case 'edit_protocol':
220
        $adminObject->displayNavigation($currentFile);
221
        $adminObject->addItemButton(_AM_XNEWSLETTER_NEWPROTOCOL, '?op=new_protocol', 'add');
222
        $adminObject->addItemButton(_AM_XNEWSLETTER_PROTOCOLLIST, '?op=list', 'list');
223
        $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left'));
224
225
        $protocolObj = $helper->getHandler('Protocol')->get(Request::getInt('protocol_id', 0));
226
        $form        = $protocolObj->getForm();
227
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
228
        break;
229 View Code Duplication
    case 'delete_protocol':
230
        $protocolId = Request::getInt('protocol_id', 0);
231
        $protocolObj = $helper->getHandler('Protocol')->get($protocolId);
232
        if (true === Request::getBool('ok', false, 'POST')) {
233
            if (!$GLOBALS['xoopsSecurity']->check()) {
234
                redirect_header($currentFile, 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
235
            }
236
            if ($helper->getHandler('Protocol')->delete($protocolObj)) {
237
                redirect_header($currentFile, 3, _AM_XNEWSLETTER_FORMDELOK);
238
            } else {
239
                $GLOBALS['xoopsTpl']->assign('error', $protocolObj->getHtmlErrors());
240
            }
241
        } else {
242
            xoops_confirm(['ok' => true, 'protocol_id' => $protocolId, 'op' => 'delete_protocol'], $_SERVER['REQUEST_URI'], sprintf(_AM_XNEWSLETTER_FORMSUREDEL, $protocolId));
243
        }
244
        break;
245
    case 'delete_protocol_list':
246
        $letter_id = Request::getInt('letter_id', -1, 'REQUEST');
247
        if ($letter_id >= 0) {
248
            $letterObj = $helper->getHandler('Letter')->get($letter_id);
249
            if (true === Request::getBool('ok', false, 'POST')) {
250
                if (!$GLOBALS['xoopsSecurity']->check()) {
251
                    redirect_header($currentFile, 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
252
                }
253
                $sql    = "DELETE FROM `{$xoopsDB->prefix('xnewsletter_protocol')}` WHERE `protocol_letter_id`={$letter_id}";
254
                $result = $xoopsDB->query($sql);
255
                if ($result) {
256
                    redirect_header($currentFile, 3, _AM_XNEWSLETTER_FORMDELOK);
257
                } else {
258
                    redirect_header($currentFile, 3, _AM_XNEWSLETTER_FORMDELNOTOK);
259
                }
260
            } else {
261
                if ($letter_id > 0) {
262
                    xoops_confirm(['ok' => true, 'letter_id' => $letter_id, 'op' => 'delete_protocol_list'], $_SERVER['REQUEST_URI'], sprintf(_AM_XNEWSLETTER_FORMSUREDEL_LIST, $letterObj->getVar('letter_title')));
263
                } else {
264
                    xoops_confirm(['ok' => true, 'letter_id' => $letter_id, 'op' => 'delete_protocol_list'], $_SERVER['REQUEST_URI'], sprintf(_AM_XNEWSLETTER_FORMSUREDEL_LIST, _AM_XNEWSLETTER_PROTOCOL_MISC));
265
                }
266
267
            }
268
        }
269
        break;
270
}
271
require_once __DIR__ . '/admin_footer.php';
272