Issues (608)

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.

admin/actions/categories.php (3 issues)

Severity
1
<?php
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
 * oledrion
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 */
19
20
/**
21
 * Gestion des catégories de produits
22
 */
23
24
use XoopsModules\Oledrion;
25
26
if (!defined('OLEDRION_ADMIN')) {
27
    exit();
28
}
29
30
switch ($action) {
31
    // ****************************************************************************************************************
32
    case 'default': // Liste des catégories
33
34
        // ****************************************************************************************************************
35
        xoops_cp_header();
36
        $adminObject = \Xmf\Module\Admin::getInstance();
37
        $adminObject->displayNavigation('index.php?op=categories');
38
39
        // Display categories **********************************************************************
40
        $categories = [];
41
        //        Oledrion\Utility::htitle(_AM_OLEDRION_CATEGORIES, 4);
42
43
        $categories = $categoryHandler->getAllCategories(new Oledrion\Parameters());
44
        $mytree     = new Oledrion\XoopsObjectTree($categories, 'cat_cid', 'cat_pid');
45
46
        $categoriesSelect0 = $mytree->makeSelectElement('id', 'cat_title', '--', '', true, 0, '', '');
47
        $categoriesSelect  = $categoriesSelect0->render();
48
49
        echo "<div class='even'><form method='post' name='quickaccess' id='quickaccess' action='$baseurl' >"
50
             . _AM_OLEDRION_LIST
51
             . " $categoriesSelect<input type='hidden' name='op' id='op' value='categories'><input type='radio' name='action' id='action' value='edit'>"
52
             . _EDIT
53
             . " <input type='radio' name='action' id='action' value='delete'>"
54
             . _DELETE
55
             . " <input type='submit' name='btnquick' id='btnquick' value='"
56
             . _GO
57
             . "'></form></div>\n";
58
        echo "<div class='odd' align='center'><form method='post' name='frmadd' id='frmadd' action='$baseurl' ><input type='hidden' name='op' id='op' value='categories'><input type='hidden' name='action' id='action' value='add'><input type='submit' name='btnadd' id='btnadd' value='"
59
             . _AM_OLEDRION_ADD_CATEG
60
             . "'></form></div>\n";
61
        echo "<br><br>\n";
62
63
        // Categories preferences *****************************************************************
64
        $chunk1    = Oledrion\Utility::getModuleOption('chunk1');
65
        $chunk2    = Oledrion\Utility::getModuleOption('chunk2');
66
        $chunk3    = Oledrion\Utility::getModuleOption('chunk3');
67
        $chunk4    = Oledrion\Utility::getModuleOption('chunk4');
68
        $positions = [0 => _AM_OLEDRION_INVISIBLE, 1 => '1', 2 => '2', 3 => '3', 4 => '4'];
69
70
        $sform = new \XoopsThemeForm(_AM_OLEDRION_CATEG_CONFIG, 'frmchunk', $baseurl);
71
        $sform->addElement(new \XoopsFormHidden('op', 'categories'));
72
        $sform->addElement(new \XoopsFormHidden('action', 'savechunks'));
73
        $sform->addElement(new \XoopsFormLabel(_AM_OLEDRION_CHUNK, _AM_OLEDRION_POSITION));
74
75
        $chunk = null;
76
        $chunk = new \XoopsFormSelect(_MI_OLEDRION_CHUNK1, 'chunk1', $chunk1, 1, false);
77
        $chunk->addOptionArray($positions);
78
        $sform->addElement($chunk, true);
79
80
        unset($chunk);
81
        $chunk = new \XoopsFormSelect(_MI_OLEDRION_CHUNK2, 'chunk2', $chunk2, 1, false);
82
        $chunk->addOptionArray($positions);
83
        $sform->addElement($chunk, true);
84
85
        unset($chunk);
86
        $chunk = new \XoopsFormSelect(_MI_OLEDRION_CHUNK3, 'chunk3', $chunk3, 1, false);
87
        $chunk->addOptionArray($positions);
88
        $sform->addElement($chunk, true);
89
90
        unset($chunk);
91
        $chunk = new \XoopsFormSelect(_MI_OLEDRION_CHUNK4, 'chunk4', $chunk4, 1, false);
92
        $chunk->addOptionArray($positions);
93
        $sform->addElement($chunk, true);
94
95
        $buttonTray = new \XoopsFormElementTray('', '');
96
        $submit_btn = new \XoopsFormButton('', 'post', _AM_OLEDRION_OK, 'submit');
97
        $buttonTray->addElement($submit_btn);
98
        $sform->addElement($buttonTray);
99
        $sform = Oledrion\Utility::formMarkRequiredFields($sform);
100
        $sform->display();
101
        require_once OLEDRION_ADMIN_PATH . 'admin_footer.php';
102
103
        break;
104
    // ****************************************************************************************************************
105
    case 'savechunks': // Save chunks order
106
107
        // ****************************************************************************************************************
108
        oledrion_set_module_option('chunk1', \Xmf\Request::getInt('chunk1', 0, 'POST'));
109
        oledrion_set_module_option('chunk2', \Xmf\Request::getInt('chunk2', 0, 'POST'));
110
        oledrion_set_module_option('chunk3', \Xmf\Request::getInt('chunk3', 0, 'POST'));
111
        oledrion_set_module_option('chunk4', \Xmf\Request::getInt('chunk4', 0, 'POST'));
112
        Oledrion\Utility::updateCache();
113
        Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=categories');
114
115
        break;
116
    // ****************************************************************************************************************
117
    case 'add': // Ajout d'une catégorie
118
119
    case 'edit': // Edition d'une catégorie
120
121
        // ****************************************************************************************************************
122
        xoops_cp_header();
123
124
        if ('edit' === $action) {
125
            $title = _AM_OLEDRION_EDIT_CATEG;
126
            $id    = \Xmf\Request::getInt('id', 0, 'POST');
127
            if (empty($id)) {
128
                Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5);
129
            }
130
            // Item exits ?
131
            $item = null;
132
            $item = $categoryHandler->get($id);
133
            if (!is_object($item)) {
134
                Oledrion\Utility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5);
135
            }
136
            $edit         = true;
137
            $label_submit = _AM_OLEDRION_MODIFY;
138
        } else {
139
            $title        = _AM_OLEDRION_ADD_CATEG;
140
            $item         = $categoryHandler->create(true);
141
            $label_submit = _AM_OLEDRION_ADD;
142
            $edit         = false;
143
        }
144
        $tbl_categories = $categoryHandler->getAllCategories(new Oledrion\Parameters());
145
        $mytree         = new Oledrion\XoopsObjectTree($tbl_categories, 'cat_cid', 'cat_pid');
146
147
        $sform = new \XoopsThemeForm($title, 'frmcategory', $baseurl);
148
        $sform->setExtra('enctype="multipart/form-data"');
149
        $sform->addElement(new \XoopsFormHidden('op', 'categories'));
150
        $sform->addElement(new \XoopsFormHidden('action', 'saveedit'));
151
        $sform->addElement(new \XoopsFormHidden('cat_cid', $item->getVar('cat_cid')));
152
        $sform->addElement(new \XoopsFormText(_AM_OLEDRION_CATEG_TITLE, 'cat_title', 50, 255, $item->getVar('cat_title', 'e')), true);
153
154
        $select_categ = $mytree->makeSelectElement('cat_pid', 'cat_title', '--', $item->getVar('cat_pid'), true, 0, '', _AM_OLEDRION_PARENT_CATEG);
155
        $sform->addElement($select_categ);
156
157
        if ('edit' === $action && $item->pictureExists()) {
158
            $pictureTray = new \XoopsFormElementTray(_AM_OLEDRION_CURRENT_PICTURE, '<br>');
159
            $pictureTray->addElement(new \XoopsFormLabel('', "<img src='" . $item->getPictureUrl() . "' alt='' border='0'>"));
160
            $deleteCheckbox = new \XoopsFormCheckBox('', 'delpicture');
161
            $deleteCheckbox->addOption(1, _DELETE);
162
            $pictureTray->addElement($deleteCheckbox);
163
            $sform->addElement($pictureTray);
164
            unset($pictureTray, $deleteCheckbox);
165
        }
166
        $sform->addElement(new \XoopsFormFile(_AM_OLEDRION_PICTURE, 'attachedfile', Oledrion\Utility::getModuleOption('maxuploadsize')), false);
167
        $editor = Oledrion\Utility::getWysiwygForm(_AM_OLEDRION_DESCRIPTION, 'cat_description', $item->getVar('cat_description', 'e'), 15, 60, 'description_hidden');
168
        if ($editor) {
0 ignored issues
show
$editor is of type XoopsFormEditor, thus it always evaluated to true.
Loading history...
169
            $sform->addElement($editor, false);
170
        }
171
172
        $editor3 = Oledrion\Utility::getWysiwygForm(_AM_OLEDRION_FOOTER, 'cat_footer', $item->getVar('cat_footer', 'e'), 15, 60, 'footer_hidden');
173
        if ($editor3) {
0 ignored issues
show
$editor3 is of type XoopsFormEditor, thus it always evaluated to true.
Loading history...
174
            $sform->addElement($editor3, false);
175
        }
176
177
        $editor2 = Oledrion\Utility::getWysiwygForm(_MI_OLEDRION_ADVERTISEMENT, 'cat_advertisement', $item->getVar('cat_advertisement', 'e'), 15, 60, 'pub_hidden');
178
        if ($editor2) {
0 ignored issues
show
$editor2 is of type XoopsFormEditor, thus it always evaluated to true.
Loading history...
179
            $sform->addElement($editor2, false);
180
        }
181
182
        // META Data
183
        if ($manual_meta) {
184
            $sform->addElement(new \XoopsFormText(_AM_OLEDRION_META_KEYWORDS, 'cat_metakeywords', 50, 255, $item->getVar('cat_metakeywords', 'e')), false);
185
            $sform->addElement(new \XoopsFormText(_AM_OLEDRION_META_DESCRIPTION, 'cat_metadescription', 50, 255, $item->getVar('cat_metadescription', 'e')), false);
186
            $sform->addElement(new \XoopsFormText(_AM_OLEDRION_META_PAGETITLE, 'cat_metatitle', 50, 255, $item->getVar('cat_metatitle', 'e')), false);
187
        }
188
189
        $buttonTray = new \XoopsFormElementTray('', '');
190
        $submit_btn = new \XoopsFormButton('', 'post', $label_submit, 'submit');
191
        $buttonTray->addElement($submit_btn);
192
        $sform->addElement($buttonTray);
193
194
        $sform = Oledrion\Utility::formMarkRequiredFields($sform);
195
        $sform->display();
196
        require_once OLEDRION_ADMIN_PATH . 'admin_footer.php';
197
198
        break;
199
    // ****************************************************************************************************************
200
    case 'saveedit': // Sauvegarde d'une catégorie
201
202
        // ****************************************************************************************************************
203
        xoops_cp_header();
204
        $id = \Xmf\Request::getInt('cat_cid', 0, 'POST');
205
        if (!empty($id)) {
206
            $edit = true;
207
            $item = $categoryHandler->get($id);
208
            if (!is_object($item)) {
209
                Oledrion\Utility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5);
210
            }
211
            $item->unsetNew();
212
            $add = false;
213
        } else {
214
            $item = $categoryHandler->create(true);
215
            $add  = true;
216
        }
217
        $opRedirect = 'categories';
218
        $item->setVars($_POST);
219
220
        if (\Xmf\Request::hasVar('delpicture', 'POST') && 1 == \Xmf\Request::getInt('delpicture', 0, 'POST')) {
221
            $item->deletePicture();
222
        }
223
224
        $destname = '';
225
        $res1     = Oledrion\Utility::uploadFile(0, OLEDRION_PICTURES_PATH);
226
        if (true === $res1) {
227
            if (Oledrion\Utility::getModuleOption('resize_others')) {
228
                // Eventuellement on redimensionne l'image
229
                Oledrion\Utility::resizePicture(OLEDRION_PICTURES_PATH . '/' . $destname, OLEDRION_PICTURES_PATH . '/' . $destname, Oledrion\Utility::getModuleOption('images_width'), Oledrion\Utility::getModuleOption('images_height'), true);
230
            }
231
            $item->setVar('cat_imgurl', basename($destname));
232
        } else {
233
            if (false !== $res1) {
234
                echo $res1;
235
            }
236
        }
237
238
        $res = $categoryHandler->insert($item);
239
        if ($res) {
240
            Oledrion\Utility::updateCache();
241
            if ($add) {
242
                //$plugins = Plugin::getInstance();
243
                //$plugins->fireAction(Plugin::EVENT_ON_CATEGORY_CREATE, new Oledrion\Parameters(array('category' => $item)));
244
            }
245
            Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
246
        } else {
247
            Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
248
        }
249
250
        break;
251
    // ****************************************************************************************************************
252
    case 'delete': // Suppression d'une catégorie
253
254
        // ****************************************************************************************************************
255
        xoops_cp_header();
256
        oledrion_adminMenu(3);
257
        $id = \Xmf\Request::getInt('id', 0, 'POST');
258
        if (0 == $id) {
259
            Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5);
260
        }
261
        $category = null;
262
        $category = $categoryHandler->get($id);
263
        if (!is_object($category)) {
264
            Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_10, $baseurl, 5);
265
        }
266
        $msg = sprintf(_AM_OLEDRION_CONF_DEL_CATEG, $category->getVar('cat_title'));
267
        xoops_confirm(['op' => 'categories', 'action' => 'confdelete', 'id' => $id], 'index.php', $msg);
268
269
        break;
270
    // ****************************************************************************************************************
271
    case 'confdelete': //Suppression effective d'une catégorie
272
273
        // ****************************************************************************************************************
274
        xoops_cp_header();
275
        $id = \Xmf\Request::getInt('id', 0, 'POST');
276
        if (empty($id)) {
277
            Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5);
278
        }
279
        $opRedirect = 'categories';
280
        // On vérifie que cette catégorie (et ses sous-catégories) ne sont pas utilisées par des produits
281
        $cnt = $categoryHandler->getCategoryProductsCount($id);
282
        if (0 == $cnt) {
283
            $item = null;
284
            $item = $categoryHandler->get($id);
285
            if (is_object($item)) {
286
                $res = $categoryHandler->deleteCategory($item);
287
                if ($res) {
288
                    Oledrion\Utility::updateCache();
289
                    Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
290
                } else {
291
                    Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
292
                }
293
            } else {
294
                Oledrion\Utility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5);
295
            }
296
        } else {
297
            Oledrion\Utility::redirect(_AM_OLEDRION_ERROR_4, $baseurl . '?op=' . $opRedirect, 5);
298
        }
299
300
        break;
301
}
302