Issues (330)

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/category.php (21 issues)

1
<?php
2
/**
3
 * Module: Lexikon - glossary module
4
 * Author: hsalazar
5
 * Licence: GNU
6
 */
7
8
use Xmf\Module\Admin;
9
use Xmf\Request;
10
use XoopsModules\Lexikon\{
11
    Helper,
12
    Utility
13
};
14
/** @var Helper $helper */
15
16
// -- General Stuff -- //
17
require_once __DIR__ . '/admin_header.php';
18
19
20
$helper = Helper::getInstance();
21
22
$myts = \MyTextSanitizer::getInstance();
23
xoops_cp_header();
24
xoops_load('XoopsUserUtility');
25
$adminObject = Admin::getInstance();
26
$adminObject->displayNavigation(basename(__FILE__));
27
$adminObject->addItemButton(_AM_LEXIKON_CREATECAT, 'category.php?op=addcat', 'add');
28
$adminObject->displayButton('left');
29
$op = '';
30
31
/* -- Available operations -- */
32
33
/**
34
 *
35
 */
36
function categoryDefault()
37
{
38
    $helper = Helper::getInstance();
39
    $op = 'default';
0 ignored issues
show
The assignment to $op is dead and can be removed.
Loading history...
40
    require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
41
    require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
42
43
    $startentry = \Xmf\Request::getInt('startentry', 0, 'GET');
0 ignored issues
show
The assignment to $startentry is dead and can be removed.
Loading history...
44
    $startcat   = \Xmf\Request::getInt('startcat', 0, 'GET');
45
    $startsub   = \Xmf\Request::getInt('startsub', 0, 'GET');
0 ignored issues
show
The assignment to $startsub is dead and can be removed.
Loading history...
46
    $datesub    = \Xmf\Request::getInt('datesub', 0, 'GET');
0 ignored issues
show
The assignment to $datesub is dead and can be removed.
Loading history...
47
48
    global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule, $entryID, $pathIcon16;
49
50
    $myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
The assignment to $myts is dead and can be removed.
Loading history...
51
    //    lx_adminMenu(1, _AM_LEXIKON_CATS);
52
    $result01 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('lxcategories') . ' ');
53
    [$totalcategories] = $xoopsDB->fetchRow($result01);
54
55
    $result02 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('lxentries') . ' WHERE submit = 0');
56
    [$totalpublished] = $xoopsDB->fetchRow($result02);
0 ignored issues
show
Comprehensibility Best Practice introduced by
This list assign is not used and could be removed.
Loading history...
57
58
    $result03 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('lxentries') . " WHERE submit = '1' AND request = '0' ");
59
    [$totalsubmitted] = $xoopsDB->fetchRow($result03);
0 ignored issues
show
Comprehensibility Best Practice introduced by
This list assign is not used and could be removed.
Loading history...
60
61
    $result04 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('lxentries') . " WHERE submit = '1' AND request = '1' ");
62
    [$totalrequested] = $xoopsDB->fetchRow($result04);
0 ignored issues
show
Comprehensibility Best Practice introduced by
This list assign is not used and could be removed.
Loading history...
63
64
    if (1 == $helper->getConfig('multicats')) {
65
        /**
66
         * Code to show existing categories
67
         **/
68
69
        echo " <table class='outer' width='100%' border='0'>
70
        <tr>
71
        <td colspan='7' class='odd'>
72
        <strong>" . _AM_LEXIKON_SHOWCATS . ' (' . $totalcategories . ')' . '</strong></td></tr>';
73
        echo '<tr>';
74
        // create existing columns table //doppio
75
        $resultC1 = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('lxcategories') . ' ');
76
        [$numrows] = $xoopsDB->fetchRow($resultC1);
77
        $sql      = 'SELECT * FROM ' . $xoopsDB->prefix('lxcategories') . ' ORDER BY weight';
78
        $resultC2 = $xoopsDB->query($sql, $helper->getConfig('perpage'), $startcat);
79
80
        echo "<th style='width:40px; text-align:center;'>" . _AM_LEXIKON_ID . "</td>
81
        <th style='text-align:center;'><b>" . _AM_LEXIKON_WEIGHT . "</b></td>
82
        <th style='width:30%; text-align:center;'>" . _AM_LEXIKON_CATNAME . "</td>
83
        <th style='width:10px; text-align:center;'>" . _AM_LEXIKON_ENTRIES . "</td>
84
        <th style='width:*; text-align:center;'>" . _AM_LEXIKON_DESCRIP . "</td>
85
        <th style='width:60px; text-align:center;'>" . _AM_LEXIKON_ACTION . '</td>
86
        </tr>';
87
88
        $class = 'odd';
89
        if ($numrows > 0) { // That is, if there ARE columns in the system
90
            while (list($categoryID, $name, $description, $total, $weight, $logourl) = $xoopsDB->fetchRow($resultC2)) {
91
                $name        = htmlspecialchars($name, ENT_QUOTES | ENT_HTML5);
92
                $description = strip_tags(htmlspecialchars_decode($description));
93
                $modify      = "<a href='category.php?op=mod&categoryID=" . $categoryID . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _AM_LEXIKON_EDITCAT . "'></a>";
94
                $delete      = "<a href='category.php?op=del&categoryID=" . $categoryID . "'><img src=" . $pathIcon16 . "/delete.png  alt='" . _AM_LEXIKON_DELETECAT . "'></a>";
95
96
                echo "<tr class='" . $class . "'>";
97
                $class = ('even' === $class) ? 'odd' : 'even';
98
99
                echo "
100
                <td style='text-align:center;'>" . $categoryID . "</td>
101
                <td style='width:10; text-align:center;'>" . $weight . "</td>
102
                <td style='text-align:left;'><a href='../category.php?categoryID=" . $categoryID . "'>" . $name . "</a></td>
103
                <td style='text-align:center;'>" . $total . "</td>
104
                <td style='text-align:left;'>" . $description . "</td>
105
                <td style='text-align:center;'>" . $modify . '-' . $delete . '</td>
106
                </tr></div>';
107
            }
108
        } else { // that is, $numrows = 0, there's no columns yet
109
            echo '<div><tr>';
110
            echo "<td class='odd' align='center' colspan= '7'>" . _AM_LEXIKON_NOCATS . '</td>';
111
            echo '</tr></div>';
112
            $categoryID = '0';
0 ignored issues
show
The assignment to $categoryID is dead and can be removed.
Loading history...
113
        }
114
        echo "</table>\n";
115
        $pagenav = new \XoopsPageNav($numrows, $helper->getConfig('perpage'), $startcat, 'startcat');
116
        echo '<div style="text-align:right;">' . $pagenav->renderNav(8) . '</div>';
117
        echo "<br><br>\n";
118
        echo '</div>';
119
    } else {
120
        redirect_header('index.php', 1, sprintf(_AM_LEXIKON_SINGLECAT, ''));
121
    }
122
}
123
124
/**
125
 * Code to edit categories
126
 * @param string $categoryID
127
 */
128
function categoryEdit($categoryID = '')
129
{
130
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
131
    require_once XOOPS_ROOT_PATH . '/class/uploader.php';
132
    require_once XOOPS_ROOT_PATH . '/class/xoopsform/grouppermform.php';
133
134
    $utility = new Utility();
135
136
    $weight      = 1;
137
    $name        = '';
138
    $description = '';
139
    $logourl     = '';
140
141
    global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule;
142
143
    $helper = Helper::getInstance();
144
145
    // If there is a parameter, and the id exists, retrieve data: we're editing a column
146
    if ($categoryID) {
147
        $result = $xoopsDB->query(
148
            '
149
                                     SELECT categoryID, name, description, total, weight,logourl
150
                                     FROM ' . $xoopsDB->prefix('lxcategories') . "
151
                                     WHERE categoryID = '$categoryID'"
152
        );
153
154
        [$categoryID, $name, $description, $total, $weight, $logourl] = $xoopsDB->fetchRow($result);
155
        $myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
The assignment to $myts is dead and can be removed.
Loading history...
156
        $name = htmlspecialchars($name, ENT_QUOTES | ENT_HTML5);
157
        //permissions
158
        /** @var \XoopsMemberHandler $memberHandler */
159
        $memberHandler = xoops_getHandler('member');
160
        $group_list    = $memberHandler->getGroupList();
0 ignored issues
show
The assignment to $group_list is dead and can be removed.
Loading history...
161
        /** @var \XoopsGroupPermHandler $grouppermHandler */
162
        $grouppermHandler = xoops_getHandler('groupperm');
163
164
        $groups = $grouppermHandler->getGroupIds('lexikon_view', $categoryID, $xoopsModule->getVar('mid'));
165
        //        $groups = $groups;
166
        if (0 == $xoopsDB->getRowsNum($result)) {
167
            redirect_header('index.php', 1, _AM_LEXIKON_NOCATTOEDIT);
168
        }
169
        if (0 == $xoopsDB->getRowsNum($result)) {
170
            redirect_header('index.php', 1, _AM_LEXIKON_NOCATTOEDIT);
171
        }
172
        //$myts = \MyTextSanitizer::getInstance();
173
        //        lx_adminMenu(1, _AM_LEXIKON_CATS);
174
175
        echo "<strong style='color: #2F5376;margin-top: 6px;font-size:medium'>" . _AM_LEXIKON_CATSHEADER . '</strong>';
176
        $sform = new \XoopsThemeForm(_AM_LEXIKON_MODCAT . ": $name", 'op', xoops_getenv('SCRIPT_NAME'), 'post', true);
177
    } else {
178
        //$myts = \MyTextSanitizer::getInstance();
179
        //        lx_adminMenu(1, _AM_LEXIKON_CATS);
180
        $groups = true;
181
        echo "<strong style='color: #2F5376;margin-top: 6px;font-size:medium'>" . _AM_LEXIKON_CATSHEADER . '</strong>';
182
        $sform = new \XoopsThemeForm(_AM_LEXIKON_NEWCAT, 'op', xoops_getenv('SCRIPT_NAME'), 'post', true);
183
    }
184
185
    $sform->setExtra('enctype="multipart/form-data"');
186
    $sform->addElement(new \XoopsFormText(_AM_LEXIKON_CATNAME, 'name', 50, 80, $name), true);
187
188
    $editor = $utility::getWysiwygForm(_AM_LEXIKON_CATDESCRIPT, 'description', $description, 7, 60);
189
    $sform->addElement($editor, true);
190
    unset($editor);
191
192
    $sform->addElement(new \XoopsFormText(_AM_LEXIKON_CATPOSIT, 'weight', 4, 4, $weight), true);
193
    $sform->addElement(new \XoopsFormHidden('categoryID', $categoryID));
194
    //CategoryImage
195
    if (1 == $helper->getConfig('useshots')) {
196
        //CategoryImage :: Common querys from Article module by phppp
197
        $image_option_tray = new \XoopsFormElementTray('<strong>' . _AM_LEXIKON_CATIMGUPLOAD . '</strong>', '<br>');
198
        $image_option_tray->addElement(new \XoopsFormFile('', 'userfile', ''));
0 ignored issues
show
'' of type string is incompatible with the type integer expected by parameter $maxfilesize of XoopsFormFile::__construct(). ( Ignorable by Annotation )

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

198
        $image_option_tray->addElement(new \XoopsFormFile('', 'userfile', /** @scrutinizer ignore-type */ ''));
Loading history...
199
        $sform->addElement($image_option_tray);
200
        unset($image_tray);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $image_tray seems to be never defined.
Loading history...
201
        unset($image_option_tray);
202
203
        $path_catimg       = 'uploads/' . $xoopsModule->getVar('dirname') . '/categories/images';
204
        $image_option_tray = new \XoopsFormElementTray(_AM_LEXIKON_CATIMAGE . '<br>' . _AM_LEXIKON_CATIMG_DSC . '<br>' . $path_catimg);
205
        $image_array       = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/' . $path_catimg . '/');
206
        array_unshift($image_array, _NONE);
207
208
        $image_select = new \XoopsFormSelect('', 'logourl', $logourl);
209
        $image_select->addOptionArray($image_array);
210
        $image_select->setExtra("onchange=\"showImgSelected('img', 'logourl', '/" . $path_catimg . "/', '', '" . XOOPS_URL . "')\"");
211
        $image_tray = new \XoopsFormElementTray('', '&nbsp;');
212
        $image_tray->addElement($image_select);
213
        if (!empty($logourl) && file_exists(XOOPS_ROOT_PATH . '/' . $path_catimg . '/' . $logourl)) {
214
            $image_tray->addElement(new \XoopsFormLabel('', "<div style='padding: 4px;'><img src=\"" . XOOPS_URL . '/' . $path_catimg . '/' . $logourl . '" name="img" id="img" alt="" ></div>'));
215
        } else {
216
            $image_tray->addElement(new \XoopsFormLabel('', "<div style='padding: 4px;'><img src=\"" . XOOPS_URL . '/' . $path_catimg . '/blank.gif" name="img" id="img" alt="" ></div>'));
217
        }
218
        $image_option_tray->addElement($image_tray);
219
        $sform->addElement($image_option_tray);
220
    }
221
    $sform->addElement(new \XoopsFormSelectGroup(_AM_LEXIKON_CAT_GROUPSVIEW, 'groups', true, $groups, 5, true));
222
223
    $buttonTray = new \XoopsFormElementTray('', '');
224
    $hidden     = new \XoopsFormHidden('op', 'addcategory');
225
    $buttonTray->addElement($hidden);
226
227
    // No ID for column -- then it's new column, button says 'Create'
228
    if (!$categoryID) {
229
        $butt_create = new \XoopsFormButton('', '', _AM_LEXIKON_CREATE, 'submit');
230
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
231
        $buttonTray->addElement($butt_create);
232
233
        $butt_clear = new \XoopsFormButton('', '', _AM_LEXIKON_CLEAR, 'reset');
234
        $buttonTray->addElement($butt_clear);
235
236
        $butt_cancel = new \XoopsFormButton('', '', _AM_LEXIKON_CANCEL, 'button');
237
        $butt_cancel->setExtra('onclick="history.go(-1)"');
238
        $buttonTray->addElement($butt_cancel);
239
    } else { // button says 'Update'
240
        $butt_create = new \XoopsFormButton('', '', _AM_LEXIKON_MODIFY, 'submit');
241
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
242
        $buttonTray->addElement($butt_create);
243
244
        $butt_cancel = new \XoopsFormButton('', '', _AM_LEXIKON_CANCEL, 'button');
245
        $butt_cancel->setExtra('onclick="history.go(-1)"');
246
        $buttonTray->addElement($butt_cancel);
247
    }
248
249
    $sform->addElement($buttonTray);
250
    $sform->display();
251
    unset($hidden);
252
}
253
254
/**
255
 * Code to delete existing categories
256
 * @param string $categoryID
257
 */
258
function categoryDelete($categoryID = '')
0 ignored issues
show
The parameter $categoryID is not used and could be removed. ( Ignorable by Annotation )

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

258
function categoryDelete(/** @scrutinizer ignore-unused */ $categoryID = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
259
{
260
    //global $xoopsDB, $xoopsConfig;
261
    global $xoopsConfig, $xoopsDB, $xoopsModule;
262
    $idc = Request::getInt('categoryID', '');
0 ignored issues
show
'' of type string is incompatible with the type integer expected by parameter $default of Xmf\Request::getInt(). ( Ignorable by Annotation )

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

262
    $idc = Request::getInt('categoryID', /** @scrutinizer ignore-type */ '');
Loading history...
263
    if ('' == $idc) {
264
        $idc = $_GET['categoryID'];
265
    }
266
    if ($idc <= 0) {
267
        header('location: category.php');
268
        exit();
269
    }
270
271
    $ok     = Request::getInt('ok', 0, 'POST'); //isset($_POST['ok']) ? \Xmf\Request::getInt('ok', 0, 'POST') : 0;
272
    $result = $xoopsDB->query('SELECT categoryID, name FROM ' . $xoopsDB->prefix('lxcategories') . " WHERE categoryID = $idc");
273
    [$categoryID, $name] = $xoopsDB->fetchRow($result);
274
    // confirmed, so delete
275
    if (1 == $ok) {
276
        //get all entries in the category
277
        $result3 = $xoopsDB->query('SELECT entryID from ' . $xoopsDB->prefix('lxentries') . " where categoryID = $idc");
278
        //now for each entry, delete the coments
279
        while (list($entryID) = $xoopsDB->fetchRow($result3)) {
280
            xoops_comment_delete($xoopsModule->getVar('mid'), $entryID);
281
            xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'term', $entryID);
282
        }
283
        $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('lxcategories') . " WHERE categoryID='$idc'");
284
        $result2 = $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('lxentries') . " WHERE categoryID = $idc");
0 ignored issues
show
The assignment to $result2 is dead and can be removed.
Loading history...
285
        // remove permissions
286
        xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_view', $categoryID);
287
        xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_submit', $categoryID);
288
        xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_approve', $categoryID);
289
        xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_request', $categoryID);
290
        // delete notifications
291
        xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'global', $categoryID);
292
        xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'category', $categoryID);
293
294
        redirect_header('category.php', 1, sprintf(_AM_LEXIKON_CATISDELETED, $name));
295
    } else {
296
        xoops_confirm(['op' => 'del', 'categoryID' => $categoryID, 'ok' => 1, 'name' => $name], 'category.php', _AM_LEXIKON_DELETETHISCAT . '<br>' . $name, _AM_LEXIKON_DELETE);
297
        require_once __DIR__ . '/admin_footer.php';
298
    }
299
}
300
301
/**
302
 * @param string $categoryID
303
 */
304
function categorySave($categoryID = '')
0 ignored issues
show
The parameter $categoryID is not used and could be removed. ( Ignorable by Annotation )

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

304
function categorySave(/** @scrutinizer ignore-unused */ $categoryID = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
305
{
306
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
307
    require_once XOOPS_ROOT_PATH . '/class/uploader.php';
308
    global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsDB, $myts, $categoryID;
309
310
    $helper = Helper::getInstance();
311
    //print_r ($_POST);
312
    $categoryID  = Request::getInt('categoryID', 0);
313
    $weight      = Request::getInt('weight', 0); //isset($_POST['weight']) ? \Xmf\Request::getInt('weight', 0, 'POST') : \Xmf\Request::getInt('weight', 0, 'GET');
314
    $name        = Request::getString('name', ''); //isset($_POST['name']) ? htmlspecialchars($_POST['name']) : htmlspecialchars($_GET['name']);
0 ignored issues
show
The assignment to $name is dead and can be removed.
Loading history...
315
    $description = htmlspecialchars(Request::getString('description', ''), ENT_QUOTES | ENT_HTML5); //isset($_POST['description']) ? htmlspecialchars($_POST['description']) : htmlspecialchars($_GET['description']);
316
    $description = &$myts->xoopsCodeDecode($myts->censorString($description), $allowimage = 1);
317
    $name        = $myts->addSlashes(Request::getString('name', '', 'POST'));
318
    $logourl     = $myts->addSlashes(Request::getString('logourl', '', 'POST'));
0 ignored issues
show
The assignment to $logourl is dead and can be removed.
Loading history...
319
    $groups      = Request::getArray('group', [], 'POST'); //isset($_POST['groups']) ? $_POST['groups'] : array();
320
    // image upload
321
    $logourl       = '';
322
    $maxfilesize   = $helper->getConfig('imguploadsize');
323
    $maxfilewidth  = $helper->getConfig('imguploadwd');
324
    $maxfileheight = $helper->getConfig('imguploadwd');
325
    if (!empty($_FILES['userfile']['name'])) {
326
        $allowed_mimetypes = [
327
            'image/gif',
328
            'image/jpeg',
329
            'image/pjpeg',
330
            'image/x-png',
331
            'image/png',
332
        ];
333
        $uploader          = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/uploads/' . $xoopsModule->getVar('dirname') . '/categories/images/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
334
335
        if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
336
            if (!$uploader->upload()) {
337
                echo $uploader->getErrors();
338
            } else {
339
                echo '<h4>' . _AM_LEXIKON_FILESUCCESS . '</h4>';
340
                $logourl = $uploader->getSavedFileName();
341
            }
342
        } else {
343
            echo $uploader->getErrors();
344
        }
345
    }
346
    $logourl = empty($logourl) ? (empty($_POST['logourl']) ? '' : $_POST['logourl']) : $logourl;
347
348
    // Run the query and update the data
349
    if (!$_POST['categoryID']) {
350
        if ($xoopsDB->query(
351
            'INSERT INTO ' . $xoopsDB->prefix('lxcategories') . " (categoryID, name, description, weight, logourl)
352
                                 VALUES (0, '$name', '$description', '$weight', '$logourl')"
353
        )) {
354
            $newid = $xoopsDB->getInsertId();
355
            // Increment author's posts count (only if it's a new definition)
356
            if (is_object($xoopsUser) && empty($categoryID)) {
357
                /** @var \XoopsMemberHandler $memberHandler */
358
                $memberHandler = xoops_getHandler('member');
359
                $submitter     = $memberHandler->getUser($uid);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $uid seems to be never defined.
Loading history...
360
                if (is_object($submitter)) {
361
                    $submitter->setVar('posts', $submitter->getVar('posts') + 1);
362
                    $res = $memberHandler->insertUser($submitter, true);
0 ignored issues
show
The assignment to $res is dead and can be removed.
Loading history...
363
                    unset($submitter);
364
                }
365
            }
366
            //notification
367
            if (!empty($helper->getConfig('notification_enabled'))) {
368
                if (0 == $newid) {
369
                    $newid = $xoopsDB->getInsertId();
370
                }
371
                global $xoopsModule;
372
                /** @var \XoopsNotificationHandler $notificationHandler */
373
                $notificationHandler = xoops_getHandler('notification');
374
                $tags                = [];
375
                $tags['ITEM_NAME']   = $name;
376
                $tags['ITEM_URL']    = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/category.php?categoryID=' . $newid;
377
                $notificationHandler->triggerEvent('global', 0, 'new_category', $tags);
378
            }
379
            lx_save_Permissions($groups, $categoryID, 'lexikon_view');
380
            redirect_header('category.php', 1, _AM_LEXIKON_CATCREATED);
381
        } else {
382
            redirect_header('index.php', 1, _AM_LEXIKON_NOTUPDATED);
383
        }
384
    } else {
385
        if ($xoopsDB->queryF(
386
            '
387
                                UPDATE ' . $xoopsDB->prefix('lxcategories') . "
388
                                SET name = '$name', description = '$description', weight = '$weight' , logourl = '$logourl'
389
                                WHERE categoryID = '$categoryID'"
390
        )) {
391
            lx_save_Permissions($groups, $categoryID, 'lexikon_view');
392
            redirect_header('category.php', 1, _AM_LEXIKON_CATMODIFIED);
393
        } else {
394
            redirect_header('index.php', 1, _AM_LEXIKON_NOTUPDATED);
395
        }
396
    }
397
}
398
399
/**
400
 * Available operations
401
 **/
402
$op = 'default';
403
if (\Xmf\Request::hasVar('op', 'POST')) {
404
    $op = $_POST['op'];
405
} else {
406
    if (\Xmf\Request::hasVar('op', 'GET')) {
407
        $op = $_GET['op'];
408
    }
409
}
410
411
switch ($op) {
412
    case 'mod':
413
        $categoryID = Request::getInt('categoryID', 0);
414
        categoryEdit($categoryID);
415
        break;
416
    case 'addcat':
417
        categoryEdit();
418
        break;
419
    case 'addcategory':
420
        categorySave();
421
        break;
422
    case 'del':
423
        categoryDelete();
424
        break;
425
    case 'default':
426
    default:
427
        categoryDefault();
428
        break;
429
}
430
require_once __DIR__ . '/admin_footer.php';
431