Issues (149)

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/rentals.php (14 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
 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
 * Module: Equipment
14
 *
15
 * @category        Module
16
 * @package         equipment
17
 * @author          swt02026 (https://github.com/swt02026/)
18
 * @author          XOOPS Development Team <http://xoops.org>
19
 * @copyright       {@link https://xoops.org/ XOOPS Project}
20
 * @license         GPL 2.0 or later
21
 * @link            https://xoops.org/
22
 * @since           1.0.0
23
 */
24
25
use Xmf\Module\Admin;
26
use Xmf\Database\Tables;
27
use Xmf\Debug;
28
use Xmf\Module\Helper;
29
use Xmf\Module\Helper\Permission;
30
use Xmf\Request;
31
32
require_once __DIR__ . '/admin_header.php';
33
xoops_cp_header();
34
//It recovered the value of argument op in URL$
35
$op    = Request::getString('op', 'list');
36
$order = Request::getString('order', 'desc');
37
$sort  = Request::getString('sort', '');
38
39
$adminObject->displayNavigation(basename(__FILE__));
40
/** @var Permission $permHelper */
41
$permHelper = new Permission($moduleDirName);
42
$uploadDir  = XOOPS_UPLOAD_PATH . '/equipment/images/';
43
$uploadUrl  = XOOPS_UPLOAD_URL . '/equipment/images/';
44
45
switch ($op) {
46
    case 'list':
47
    default:
48
        $adminObject->addItemButton(AM_EQUIPMENT_ADD_RENTALS, 'rentals.php?op=new', 'add');
49
        echo $adminObject->displayButton('left');
50
        $start                  = Request::getInt('start', 0);
51
        $rentalsPaginationLimit = $GLOBALS['xoopsModuleConfig']['userpager'];
52
53
        $criteria = new CriteriaCompo();
54
        $criteria->setSort('id ASC, customerid');
55
        $criteria->setOrder('ASC');
56
        $criteria->setLimit($rentalsPaginationLimit);
57
        $criteria->setStart($start);
58
    /** @var EquipmentRentalsHandler $rentalsHandler */
59
        $rentalsTempRows = $rentalsHandler->getCount();
60
        $rentalsTempArray = $rentalsHandler->getAll($criteria);/*
61
//
62
// 
63
                    <th class='center width5'>".AM_EQUIPMENT_FORM_ACTION."</th>
64
//                    </tr>";
65
//            $class = "odd";
66
*/
67
68
        // Display Page Navigation
69 View Code Duplication
        if ($rentalsTempRows > $rentalsPaginationLimit) {
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...
70
            require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
71
72
            $pagenav = new XoopsPageNav($rentalsTempRows, $rentalsPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . '');
73
            $GLOBALS['xoopsTpl']->assign('pagenav', null === $pagenav ? $pagenav->renderNav() : '');
74
        }
75
76
        $GLOBALS['xoopsTpl']->assign('rentalsRows', $rentalsTempRows);
77
        $rentalsArray = array();
78
79
        //    $fields = explode('|', id:smallint:5:unsigned:NOT NULL::primary:ID|customerid:int:5::NOT NULL::primary:Customer|equipmentid:int:10:unsigned:NOT NULL:::Equipment|quantity:int:8::NOT NULL:::Quantity|datefrom:datetime:::NOT NULL:::From|dateto:datetime:::NOT NULL:::To);
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
80
        //    $fieldsCount    = count($fields);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
81
82
        $criteria = new CriteriaCompo();
83
84
        //$criteria->setOrder('DESC');
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
85
        $criteria->setSort($sort);
86
        $criteria->setOrder($order);
87
        $criteria->setLimit($rentalsPaginationLimit);
88
        $criteria->setStart($start);
89
90
        $rentalsCount     = $rentalsHandler->getCount($criteria);
91
        $rentalsTempArray = $rentalsHandler->getAll($criteria);
92
93
        //    for ($i = 0; $i < $fieldsCount; ++$i) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
94
        if ($rentalsCount > 0) {
95
            foreach (array_keys($rentalsTempArray) as $i) {
96
97
98
                //        $field = explode(':', $fields[$i]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
99
100
                $selectorid = EquipmentUtility::selectSorting(AM_EQUIPMENT_RENTALS_ID, 'id');
101
                $GLOBALS['xoopsTpl']->assign('selectorid', $selectorid);
102
                $rentalsArray['id'] = $rentalsTempArray[$i]->getVar('id');
103
104
                $selectorcustomerid = EquipmentUtility::selectSorting(AM_EQUIPMENT_RENTALS_CUSTOMERID, 'customerid');
105
                $GLOBALS['xoopsTpl']->assign('selectorcustomerid', $selectorcustomerid);
106 View Code Duplication
                if(null !==($customerHandler->get($rentalsTempArray[$i]->getVar('customerid')))) {
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...
107
                    $rentalsArray['customerid'] = $customerHandler->get($rentalsTempArray[$i]->getVar('customerid'))->getVar('last');
108
                }
109
110
                $selectorequipmentid = EquipmentUtility::selectSorting(AM_EQUIPMENT_RENTALS_EQUIPMENTID, 'equipmentid');
111
                $GLOBALS['xoopsTpl']->assign('selectorequipmentid', $selectorequipmentid);
112 View Code Duplication
                if(null !==($equipmentHandler->get($rentalsTempArray[$i]->getVar('equipmentid')))) {
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...
113
                    $rentalsArray['equipmentid'] = $equipmentHandler->get($rentalsTempArray[$i]->getVar('equipmentid'))->getVar('name');
114
                }
115
116
                $selectorquantity = EquipmentUtility::selectSorting(AM_EQUIPMENT_RENTALS_QUANTITY, 'quantity');
117
                $GLOBALS['xoopsTpl']->assign('selectorquantity', $selectorquantity);
118
                $rentalsArray['quantity'] = $rentalsTempArray[$i]->getVar('quantity');
119
120
                $selectordatefrom = EquipmentUtility::selectSorting(AM_EQUIPMENT_RENTALS_DATEFROM, 'datefrom');
121
                $GLOBALS['xoopsTpl']->assign('selectordatefrom', $selectordatefrom);
122
                $rentalsArray['datefrom'] = date(_SHORTDATESTRING, strtotime($rentalsTempArray[$i]->getVar('datefrom')));
123
124
                $selectordateto = EquipmentUtility::selectSorting(AM_EQUIPMENT_RENTALS_DATETO, 'dateto');
125
                $GLOBALS['xoopsTpl']->assign('selectordateto', $selectordateto);
126
                $rentalsArray['dateto']      = date(_SHORTDATESTRING, strtotime($rentalsTempArray[$i]->getVar('dateto')));
127
                $rentalsArray['edit_delete'] = "<a href='rentals.php?op=edit&id=" . $i . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a>
128
               <a href='rentals.php?op=delete&id=" . $i . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a>
129
               <a href='rentals.php?op=clone&id=" . $i . "'><img src=" . $pathIcon16 . "/editcopy.png alt='" . _CLONE . "' title='" . _CLONE . "'></a>";
130
131
                $GLOBALS['xoopsTpl']->append_by_ref('rentalsArrays', $rentalsArray);
132
                unset($rentalsArray);
133
            }
134
            unset($rentalsTempArray);
135
            // Display Navigation
136 View Code Duplication
            if ($rentalsCount > $rentalsPaginationLimit) {
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...
137
                require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
138
                $pagenav = new XoopsPageNav($rentalsCount, $rentalsPaginationLimit, $start, 'start', 'op=list' . '&sort=' . $sort . '&order=' . $order . '');
139
                $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
140
            }
141
142
            //                     echo "<td class='center width5'>
143
144
            //                    <a href='rentals.php?op=edit&id=".$i."'><img src=".$pathIcon16."/edit.png alt='"._EDIT."' title='"._EDIT."'></a>
145
            //                    <a href='rentals.php?op=delete&id=".$i."'><img src=".$pathIcon16."/delete.png alt='"._DELETE."' title='"._DELETE."'></a>
146
            //                    </td>";
147
148
            //                echo "</tr>";
149
150
            //            }
151
152
            //            echo "</table><br><br>";
153
154
            //        } else {
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
155
156
            //            echo "<table width='100%' cellspacing='1' class='outer'>
157
158
            //                    <tr>
159
160
            //                     <th class='center width5'>".AM_EQUIPMENT_FORM_ACTION."XXX</th>
161
            //                    </tr><tr><td class='errorMsg' colspan='7'>There are noXXX rentals</td></tr>";
162
            //            echo "</table><br><br>";
163
164
            //-------------------------------------------
165
166
            echo $GLOBALS['xoopsTpl']->fetch(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . '/templates/admin/equipment_admin_rentals.tpl');
167
        }
168
169
        break;
170
171 View Code Duplication
    case 'new':
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...
172
        $adminObject->addItemButton(AM_EQUIPMENT_RENTALS_LIST, 'rentals.php', 'list');
173
        echo $adminObject->displayButton('left');
174
175
        $rentalsObject = $rentalsHandler->create();
176
        $form          = $rentalsObject->getForm();
177
        $form->display();
178
        break;
179
180
    case 'save':
181
        if (!$GLOBALS['xoopsSecurity']->check()) {
182
            redirect_header('rentals.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
183
        }
184
        if (0 != Request::getInt('id', 0)) {
185
            $rentalsObject = $rentalsHandler->get(Request::getInt('id', 0));
186
        } else {
187
            $rentalsObject = $rentalsHandler->create();
188
        }
189
        // Form save fields
190
        $rentalsObject->setVar('customerid', Request::getVar('customerid', ''));
191
        $rentalsObject->setVar('equipmentid', Request::getVar('equipmentid', ''));
192
        $rentalsObject->setVar('quantity', Request::getVar('quantity', ''));
193
        $rentalsObject->setVar('datefrom', $_REQUEST['datefrom']);
194
        $rentalsObject->setVar('dateto', $_REQUEST['dateto']);
195
        if ($rentalsHandler->insert($rentalsObject)) {
196
            redirect_header('rentals.php?op=list', 2, AM_EQUIPMENT_FORMOK);
197
        }
198
199
        echo $rentalsObject->getHtmlErrors();
200
        $form = $rentalsObject->getForm();
201
        $form->display();
202
        break;
203
204 View Code Duplication
    case 'edit':
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...
205
        $adminObject->addItemButton(AM_EQUIPMENT_ADD_RENTALS, 'rentals.php?op=new', 'add');
206
        $adminObject->addItemButton(AM_EQUIPMENT_RENTALS_LIST, 'rentals.php', 'list');
207
        echo $adminObject->displayButton('left');
208
        $rentalsObject = $rentalsHandler->get(Request::getString('id', ''));
209
        $form          = $rentalsObject->getForm();
210
        $form->display();
211
        break;
212
213 View Code Duplication
    case 'delete':
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...
214
        $rentalsObject = $rentalsHandler->get(Request::getString('id', ''));
215
        if (1 == Request::getInt('ok', 0)) {
216
            if (!$GLOBALS['xoopsSecurity']->check()) {
217
                redirect_header('rentals.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
218
            }
219
            if ($rentalsHandler->delete($rentalsObject)) {
220
                redirect_header('rentals.php', 3, AM_EQUIPMENT_FORMDELOK);
221
            } else {
222
                echo $rentalsObject->getHtmlErrors();
223
            }
224
        } else {
225
            xoops_confirm(array(
226
                              'ok' => 1,
227
                              'id' => Request::getString('id', ''),
228
                              'op' => 'delete'
229
                          ), Request::getCmd('REQUEST_URI', '', 'SERVER'), sprintf(AM_EQUIPMENT_FORMSUREDEL, $rentalsObject->getVar('customerid')));
230
        }
231
        break;
232
233 View Code Duplication
    case 'clone':
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...
234
235
        $id_field = Request::getString('id', '');
236
237
        if (EquipmentUtility::cloneRecord('equipment_rentals', 'id', $id_field)) {
238
            redirect_header('rentals.php', 3, AM_EQUIPMENT_CLONED_OK);
239
        } else {
240
            redirect_header('rentals.php', 3, AM_EQUIPMENT_CLONED_FAILED);
241
        }
242
243
        break;
244
}
245
require_once __DIR__ . '/admin_footer.php';
246