Issues (1844)

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/file.php (3 issues)

1
<?php declare(strict_types=1);
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    {@link https://xoops.org/ XOOPS Project}
15
 * @license      {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
16
 * @author       Brian Wahoff <[email protected]>
17
 * @author       Eric Juden <[email protected]>
18
 * @author       XOOPS Development Team
19
 */
20
21
use Xmf\Module\Admin;
22
use Xmf\Request;
23
use XoopsModules\Xhelp;
24
25
require_once __DIR__ . '/admin_header.php';
26
xoops_load('XoopsPagenav');
27
28
global $xoopsModule;
29
$module_id = $xoopsModule->getVar('mid');
30
$helper    = Xhelp\Helper::getInstance();
31
32
$limit = Request::getInt('limit', 0, 'REQUEST');
33
34
$start = Request::getInt('start', 15, 'REQUEST');
35
36
if (Request::hasVar('order', 'REQUEST')) {
37
    $order = $_REQUEST['order'];
38
} else {
39
    $order = 'ASC';
40
}
41
if (Request::hasVar('sort', 'REQUEST')) {
42
    $sort = $_REQUEST['sort'];
43
} else {
44
    $sort = 'id';
45
}
46
47
$aSortBy  = [
48
    'id'       => _AM_XHELP_TEXT_ID,
49
    'ticketid' => _AM_XHELP_TEXT_TICKETID,
50
    'filename' => _AM_XHELP_TEXT_FILENAME,
51
    'mimetype' => _AM_XHELP_TEXT_MIMETYPE,
52
];
53
$aOrderBy = ['ASC' => _AM_XHELP_TEXT_ASCENDING, 'DESC' => _AM_XHELP_TEXT_DESCENDING];
54
$aLimitBy = ['10' => 10, '15' => 15, '20' => 20, '25' => 25, '50' => 50, '100' => 100];
55
56
$op = 'default';
57
58
if (Request::hasVar('op', 'REQUEST')) {
59
    $op = \Xmf\Request::getString('op', '', 'REQUEST');
60
}
61
62
switch ($op) {
63
    case 'deleteFile':
64
        deleteFile();
65
        break;
66
    case 'deleteResolved':
67
        deleteResolved();
68
        break;
69
    case 'manageFiles':
70
        manageFiles();
71
        break;
72
    default:
73
        $helper->redirect('admin/index.php');
74
        break;
75
}
76
77
/**
78
 *
79
 */
80
function deleteFile()
81
{
82
    $helper = Xhelp\Helper::getInstance();
83
    /** @var \XoopsModules\Xhelp\FileHandler $fileHandler */
84
    $fileHandler = $helper->getHandler('File');
85
86
    if (!isset($_GET['fileid'])) {
87
        $helper->redirect('admin/file.php?op=manageFiles', 3, _XHELP_MESSAGE_DELETE_FILE_ERR);
88
    }
89
    $fileid = Request::getInt('fileid', 0, 'GET');
90
    if (isset($_POST['ok'])) {
91
        $file = $fileHandler->get($fileid);
92
        if ($fileHandler->delete($file, true)) {
93
            $helper->redirect('admin/file.php?op=manageFiles');
94
        }
95
        $helper->redirect('admin/file.php?op=manageFiles', 3, _XHELP_MESSAGE_DELETE_FILE_ERR);
96
    } else {
97
        xoops_cp_header();
98
        xoops_confirm(['op' => 'deleteFile', 'ok' => 1], XHELP_ADMIN_URL . '/file.php?fileid=' . $fileid, _AM_XHELP_MSG_DELETE_FILE);
0 ignored issues
show
The constant XHELP_ADMIN_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
99
        xoops_cp_footer();
100
    }
101
}
102
103
/**
104
 *
105
 */
106
function deleteResolved()
107
{
108
    $helper = Xhelp\Helper::getInstance();
109
    if (isset($_POST['ok'])) {
110
        /** @var \XoopsModules\Xhelp\TicketHandler $ticketHandler */
111
        $ticketHandler = $helper->getHandler('Ticket');
112
        /** @var \XoopsModules\Xhelp\FileHandler $fileHandler */
113
        $fileHandler = $helper->getHandler('File');
114
115
        $tickets = $ticketHandler->getObjectsByState(1);     // Memory saver - unresolved should be less tickets
116
117
        $aTickets = [];
118
        foreach ($tickets as $ticket) {
119
            $aTickets[$ticket->getVar('id')] = $ticket->getVar('id');
120
        }
121
122
        // Retrieve all unresolved ticket attachments
123
        $criteria = new \CriteriaCompo();
124
        foreach ($aTickets as $ticket) {
125
            $criteria->add(new \Criteria('ticketid', $ticket, '!='));
126
        }
127
        if ($fileHandler->deleteAll($criteria)) {
128
            $helper->redirect('admin/file.php?op=manageFiles');
129
        } else {
130
            $helper->redirect('admin/file.php?op=manageFiles', 3, _XHELP_MESSAGE_DELETE_FILE_ERR);
131
        }
132
    } else {
133
        xoops_cp_header();
134
        //echo $oAdminButton->renderButtons('manFiles');
135
        $adminObject = Admin::getInstance();
136
        $adminObject->displayNavigation(basename(__FILE__));
137
138
        xoops_confirm(['op' => 'deleteResolved', 'ok' => 1], XHELP_BASE_URL . '/admin/file.php', _AM_XHELP_MSG_DELETE_RESOLVED);
139
        xoops_cp_footer();
140
    }
141
}
142
143
/**
144
 *
145
 */
146
function manageFiles()
147
{
148
    global $aSortBy, $aOrderBy, $aLimitBy, $order, $limit, $start, $sort;
149
    $xhelpUploadDir = XHELP_UPLOAD_PATH;
0 ignored issues
show
The constant XHELP_UPLOAD_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
150
    $dir_status     = xhelp_admin_getPathStatus($xhelpUploadDir, true);
151
    $helper         = Xhelp\Helper::getInstance();
152
153
    if (-1 == $dir_status) {
154
        $can_upload = xhelp_admin_mkdir($xhelpUploadDir);
155
    }
156
157
    /** @var \XoopsModules\Xhelp\FileHandler $fileHandler */
158
    $fileHandler = $helper->getHandler('File');
159
160
    if (Request::hasVar('deleteFiles', 'POST')) {   // Delete all selected files
161
        $aFiles   = $_POST['files'];
162
        $criteria = new \Criteria('id', '(' . implode(',', $aFiles) . ')', 'IN');
163
164
        if ($fileHandler->deleteAll($criteria)) {
165
            $helper->redirect('admin/file.php?op=manageFiles');
166
        }
167
        $helper->redirect('admin/file.php?op=manageFiles', 3, _XHELP_MESSAGE_DELETE_FILE_ERR);
168
    }
169
    xoops_cp_header();
170
    //echo $oAdminButton->renderButtons('manFiles');
171
    $adminObject = Admin::getInstance();
172
    $adminObject->displayNavigation('file.php?op=manageFiles');
173
174
    echo '<script type="text/javascript" src="' . XOOPS_URL . '/modules/xhelp/include/functions.js"></script>';
175
    echo "<form method='post' action='" . XHELP_ADMIN_URL . "/file.php?op=manageFiles'>";
0 ignored issues
show
The constant XHELP_ADMIN_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
176
177
    echo "<table width='100%' cellspacing='1' class='outer'>
178
          <tr><th colspan='2'><label>" . _AM_XHELP_TEXT_TOTAL_USED_SPACE . '</label></th></tr>';
179
180
    echo "<tr><td class='head' width='20%'>" . _AM_XHELP_TEXT_ALL_ATTACH . "</td>
181
              <td class='even'>" . xhelpDirsize($xhelpUploadDir) . '
182
              </td>
183
          </tr>';
184
185
    $resolvedSize = xhelpDirsize($xhelpUploadDir, true);
186
    echo "<tr><td class='head'>" . _AM_XHELP_TEXT_RESOLVED_ATTACH . "</td>
187
              <td class='even'>";
188
    if ($resolvedSize > 0) {
189
        echo $resolvedSize . ' <b>(' . _AM_XHELP_TEXT_DELETE_RESOLVED . "
190
                  <a href='" . XHELP_ADMIN_URL . "/file.php?op=deleteResolved'><img src='" . XHELP_IMAGE_URL . "/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE . "' name='deleteFile'></a>)</b>";
191
    } else {
192
        echo $resolvedSize;
193
    }
194
    echo '</td>
195
          </tr>';
196
    echo '</table></form>';
197
198
    $criteria = new \Criteria('', '');
199
    $criteria->setOrder($order);
200
    $criteria->setSort($sort);
201
    $criteria->setLimit($limit);
202
    $criteria->setStart($start);
203
    $files = $fileHandler->getObjects($criteria);
204
    $total = $fileHandler->getCount($criteria);
205
206
    $nav = new \XoopsPageNav($total, $limit, $start, 'start', "op=manageFiles&amp;limit=$limit");
207
208
    echo "<form action='" . XHELP_ADMIN_URL . "/file.php?op=manageFiles' style='margin:0; padding:0;' method='post'>";
209
    echo $GLOBALS['xoopsSecurity']->getTokenHTML();
210
    echo "<table width='100%' cellspacing='1' class='outer'>";
211
    echo "<tr><td align='right'>" . _AM_XHELP_TEXT_SORT_BY . "
212
                  <select name='sort'>";
213
    foreach ($aSortBy as $value => $text) {
214
        ($sort == $value) ? $selected = 'selected' : $selected = '';
215
        echo "<option value='$value' $selected>$text</option>";
216
    }
217
    echo '</select>
218
                &nbsp;&nbsp;&nbsp;
219
                  ' . _AM_XHELP_TEXT_ORDER_BY . "
220
                  <select name='order'>";
221
    foreach ($aOrderBy as $value => $text) {
222
        ($order == $value) ? $selected = 'selected' : $selected = '';
223
        echo "<option value='$value' $selected>$text</option>";
224
    }
225
    echo '</select>
226
                  &nbsp;&nbsp;&nbsp;
227
                  ' . _AM_XHELP_TEXT_NUMBER_PER_PAGE . "
228
                  <select name='limit'>";
229
    foreach ($aLimitBy as $value => $text) {
230
        ($limit == $value) ? $selected = 'selected' : $selected = '';
231
        echo "<option value='$value' $selected>$text</option>";
232
    }
233
    echo "</select>
234
                  <input type='submit' name='file_sort' id='file_sort' value='" . _AM_XHELP_BUTTON_SUBMIT . "'>
235
              </td>
236
          </tr>";
237
    echo '</table></form>';
238
239
    echo "<form method='post' action='" . XHELP_ADMIN_URL . "/file.php?op=manageFiles'>";
240
    echo "<table width='100%' cellspacing='1' class='outer'>
241
          <tr><th colspan='6'><label>" . _AM_XHELP_TEXT_MANAGE_FILES . '</label></th></tr>';
242
    if (0 != $total) {
243
        echo "<tr class='head'>
244
                  <td>" . _AM_XHELP_TEXT_ID . '</td>
245
                  <td>' . _AM_XHELP_TEXT_TICKETID . '</td>
246
                  <td>' . _AM_XHELP_TEXT_FILENAME . '</td>
247
                  <td>' . _AM_XHELP_TEXT_SIZE . '</td>
248
                  <td>' . _AM_XHELP_TEXT_MIMETYPE . '</td>
249
                  <td>' . _AM_XHELP_TEXT_ACTIONS . '</td>
250
              </tr>';
251
252
        foreach ($files as $file) {
253
            $filepath   = XHELP_BASE_URL . '/viewFile.php?id=' . $file->getVar('id');
254
            $ticketpath = XHELP_BASE_URL . '/ticket.php?id=' . $file->getVar('ticketid');
255
            $filesize   = filesize($xhelpUploadDir . '/' . $file->getVar('filename'));
256
257
            echo "<tr class='even'>
258
                      <td><input type='checkbox' name='files[]' value='" . $file->getVar('id') . "'> " . $file->getVar('id') . "</td>
259
                      <td><a href='" . $ticketpath . "' target='_BLANK'>" . $file->getVar('ticketid') . "</a></td>
260
                      <td><a href='" . $filepath . "'>" . $file->getVar('filename') . '</a></td>
261
                      <td>' . Xhelp\Utility::prettyBytes($filesize) . '</td>
262
                      <td>' . $file->getVar('mimetype') . "</td>
263
                      <td>
264
                          <a href='" . XHELP_ADMIN_URL . '/file.php?op=deleteFile&amp;fileid=' . $file->getVar('id') . "'><img src='" . XOOPS_URL . "/modules/xhelp/assets/images/button_delete.png' title='" . _AM_XHELP_TEXT_DELETE . "' name='deleteFile'></a>
265
                      </td>
266
                 </tr>";
267
        }
268
        echo "<tr class='foot'><td colspan='6'>
269
                                   <input type='checkbox' name='checkAllFiles' value='0' onclick='selectAll(this.form,\"files[]\",this.checked);'>
270
                                   <input type='submit' name='deleteFiles' id='deleteFiles' value='" . _AM_XHELP_BUTTON_DELETE . "'></td></tr>";
271
        echo '</table></form>';
272
        echo "<div id='status_nav'>" . $nav->renderNav() . '</div>';
273
    } else {
274
        echo "<tr class='even'<td colspan='6'>" . _AM_XHELP_TEXT_NO_FILES . '</td></tr>';
275
        echo '</table></form>';
276
    }
277
278
    require_once __DIR__ . '/admin_footer.php';
279
}
280