Issues (964)

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.

testdata/mymodule3/admin/testfields.php (2 issues)

Labels
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
 * My Module 3 module for xoops
14
 *
15
 * @copyright     2020 XOOPS Project (https://xooops.org)
16
 * @license        GPL 2.0 or later
17
 * @package        mymodule3
18
 * @since          1.0
19
 * @min_xoops      2.5.9
20
 * @author         TDM XOOPS - Email:<[email protected]> - Website:<http://xoops.org>
21
 */
22
23
use Xmf\Request;
24
use XoopsModules\Mymodule3;
25
use XoopsModules\Mymodule3\Constants;
26
27
require __DIR__ . '/header.php';
28
// It recovered the value of argument op in URL$
29
$op = Request::getString('op', 'list');
30
// Request tf_id
31
$tfId = Request::getInt('tf_id');
32
switch($op) {
33
	case 'list':
34
	default:
35
		// Define Stylesheet
36
		$GLOBALS['xoTheme']->addStylesheet( $style, null );
37
		$start = Request::getInt('start', 0);
38
		$limit = Request::getInt('limit', $helper->getConfig('adminpager'));
39
		$templateMain = 'mymodule3_admin_testfields.tpl';
40
		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('testfields.php'));
41
		$adminObject->addItemButton(_AM_MYMODULE3_ADD_TESTFIELD, 'testfields.php?op=new', 'add');
42
		$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
43
		$testfieldsCount = $testfieldsHandler->getCountTestfields();
44
		$testfieldsAll = $testfieldsHandler->getAllTestfields($start, $limit);
45
		$GLOBALS['xoopsTpl']->assign('testfields_count', $testfieldsCount);
46
		$GLOBALS['xoopsTpl']->assign('mymodule3_url', MYMODULE3_URL);
47
		$GLOBALS['xoopsTpl']->assign('mymodule3_upload_url', MYMODULE3_UPLOAD_URL);
48
		// Table view testfields
49
		if ($testfieldsCount > 0) {
50
			foreach(array_keys($testfieldsAll) as $i) {
51
				$testfield = $testfieldsAll[$i]->getValuesTestfields();
52
				$GLOBALS['xoopsTpl']->append('testfields_list', $testfield);
53
				unset($testfield);
54
			}
55
			// Display Navigation
56
			if ($testfieldsCount > $limit) {
57
				include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
58
				$pagenav = new \XoopsPageNav($testfieldsCount, $limit, $start, 'start', 'op=list&limit=' . $limit);
59
				$GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
60
			}
61
		} else {
62
			$GLOBALS['xoopsTpl']->assign('error', _AM_MYMODULE3_THEREARENT_TESTFIELDS);
63
		}
64
	break;
65
	case 'new':
66
		$templateMain = 'mymodule3_admin_testfields.tpl';
67
		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('testfields.php'));
68
		$adminObject->addItemButton(_AM_MYMODULE3_TESTFIELDS_LIST, 'testfields.php', 'list');
69
		$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
70
		// Get Form
71
		$testfieldsObj = $testfieldsHandler->create();
72
		$form = $testfieldsObj->getFormTestfields();
73
		$GLOBALS['xoopsTpl']->assign('form', $form->render());
74
	break;
75
	case 'save':
76
		// Security Check
77
		if (!$GLOBALS['xoopsSecurity']->check()) {
78
			redirect_header('testfields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
79
		}
80
		if (isset($tfId)) {
81
			$testfieldsObj = $testfieldsHandler->get($tfId);
82
		} else {
83
			$testfieldsObj = $testfieldsHandler->create();
84
		}
85
		// Set Vars
86
		$testfieldsObj->setVar('tf_text', Request::getString('tf_text', ''));
87
		$testfieldsObj->setVar('tf_textarea', Request::getString('tf_textarea', ''));
88
		$testfieldsObj->setVar('tf_dhtml', Request::getString('tf_dhtml', ''));
89
		$testfieldsObj->setVar('tf_checkbox', Request::getInt('tf_checkbox', 0));
90
		$testfieldsObj->setVar('tf_yesno', Request::getInt('tf_yesno', 0));
91
		$testfieldsObj->setVar('tf_selectbox', Request::getInt('tf_selectbox', 0));
92
		$testfieldsObj->setVar('tf_user', Request::getInt('tf_user', 0));
93
		$testfieldsObj->setVar('tf_color', Request::getString('tf_color', ''));
94
		// Set Var tf_imagelist
95
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
96
		$uploader = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32', 
97
													$helper->getConfig('mimetypes_image'), 
98
													$helper->getConfig('maxsize_image'), null, null);
99
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
100
			//$uploader->setPrefix(tf_imagelist_);
101
			//$uploader->fetchMedia($_POST['xoops_upload_file'][0]);
102
			if (!$uploader->upload()) {
103
				$errors = $uploader->getErrors();
104
				redirect_header('javascript:history.go(-1).php', 3, $errors);
105
			} else {
106
				$testfieldsObj->setVar('tf_imagelist', $uploader->getSavedFileName());
107
			}
108
		} else {
109
			$testfieldsObj->setVar('tf_imagelist', Request::getString('tf_imagelist'));
110
		}
111
		$testfieldsObj->setVar('tf_urlfile', formatUrl($_REQUEST['tf_urlfile']));
112
		// Set Var tf_urlfile
113
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
114
		$filename       = $_FILES['tf_urlfile']['name'];
115
		$imgNameDef     = Request::getString('tf_text');
116
		$uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', 
117
													$helper->getConfig('mimetypes_file'), 
118
													$helper->getConfig('maxsize_file'), null, null);
119
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) {
120
			$extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename);
121
			$imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension;
122
			$uploader->setPrefix($imgName);
123
			$uploader->fetchMedia($_POST['xoops_upload_file'][1]);
124
			if (!$uploader->upload()) {
125
				$errors = $uploader->getErrors();
126
			} else {
127
				$testfieldsObj->setVar('tf_urlfile', $uploader->getSavedFileName());
128
			}
129
		} else {
130
			if ($filename > '') {
131
				$uploaderErrors = $uploader->getErrors();
132
			}
133
			$testfieldsObj->setVar('tf_urlfile', Request::getString('tf_urlfile'));
134
		}
135
		// Set Var tf_uplimage
136
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
137
		$filename       = $_FILES['tf_uplimage']['name'];
138
		$imgMimetype    = $_FILES['tf_uplimage']['type'];
139
		$imgNameDef     = Request::getString('tf_text');
140
		$uploaderErrors = '';
141
		$uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/', 
142
													$helper->getConfig('mimetypes_image'), 
143
													$helper->getConfig('maxsize_image'), null, null);
144
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][2])) {
145
			$extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename);
146
			$imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension;
147
			$uploader->setPrefix($imgName);
148
			$uploader->fetchMedia($_POST['xoops_upload_file'][2]);
149
			if (!$uploader->upload()) {
150
				$uploaderErrors = $uploader->getErrors();
151
			} else {
152
				$savedFilename = $uploader->getSavedFileName();
153
				$maxwidth  = (int)$helper->getConfig('maxwidth_image');
154
				$maxheight = (int)$helper->getConfig('maxheight_image');
155
				if ($maxwidth > 0 && $maxheight > 0) {
156
					// Resize image
157
					$imgHandler                = new Mymodule3\Common\Resizer();
158
					$imgHandler->sourceFile    = MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename;
159
					$imgHandler->endFile       = MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename;
160
					$imgHandler->imageMimetype = $imgMimetype;
161
					$imgHandler->maxWidth      = $maxwidth;
162
					$imgHandler->maxHeight     = $maxheight;
163
					$result                    = $imgHandler->resizeImage();
164
				}
165
				$testfieldsObj->setVar('tf_uplimage', $savedFilename);
166
			}
167
		} else {
168
			if ($filename > '') {
169
				$uploaderErrors = $uploader->getErrors();
170
			}
171
			$testfieldsObj->setVar('tf_uplimage', Request::getString('tf_uplimage'));
172
		}
173
		// Set Var tf_uplfile
174
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
175
		$filename       = $_FILES['tf_uplfile']['name'];
176
		$imgNameDef     = Request::getString('tf_text');
177
		$uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', 
178
													$helper->getConfig('mimetypes_file'), 
179
													$helper->getConfig('maxsize_file'), null, null);
180
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][3])) {
181
			$extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename);
182
			$imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension;
183
			$uploader->setPrefix($imgName);
184
			$uploader->fetchMedia($_POST['xoops_upload_file'][3]);
185
			if (!$uploader->upload()) {
186
				$errors = $uploader->getErrors();
187
			} else {
188
				$testfieldsObj->setVar('tf_uplfile', $uploader->getSavedFileName());
189
			}
190
		} else {
191
			if ($filename > '') {
192
				$uploaderErrors = $uploader->getErrors();
193
			}
194
			$testfieldsObj->setVar('tf_uplfile', Request::getString('tf_uplfile'));
195
		}
196
		$testfieldTextdateselect = date_create_from_format(_SHORTDATESTRING, Request::getString('tf_textdateselect'));
197
		$testfieldsObj->setVar('tf_textdateselect', $testfieldTextdateselect->getTimestamp());
198
		// Set Var tf_selectfile
199
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
200
		$filename       = $_FILES['tf_selectfile']['name'];
201
		$imgNameDef     = Request::getString('tf_text');
202
		$uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', 
203
													$helper->getConfig('mimetypes_file'), 
204
													$helper->getConfig('maxsize_file'), null, null);
205
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][4])) {
206
			$extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename);
207
			$imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension;
208
			$uploader->setPrefix($imgName);
209
			$uploader->fetchMedia($_POST['xoops_upload_file'][4]);
210
			if (!$uploader->upload()) {
211
				$errors = $uploader->getErrors();
212
			} else {
213
				$testfieldsObj->setVar('tf_selectfile', $uploader->getSavedFileName());
214
			}
215
		} else {
216
			if ($filename > '') {
217
				$uploaderErrors = $uploader->getErrors();
218
			}
219
			$testfieldsObj->setVar('tf_selectfile', Request::getString('tf_selectfile'));
220
		}
221
		$tfPassword = Request::getString('tf_password', '');
222
		if ('' !== $tfPassword) {
223
			$testfieldsObj->setVar('tf_password', password_hash($tfPassword, PASSWORD_DEFAULT));
224
		}
225
		$testfieldsObj->setVar('tf_country_list', Request::getString('tf_country_list', ''));
226
		$testfieldsObj->setVar('tf_language', Request::getString('tf_language', ''));
227
		$testfieldsObj->setVar('tf_radio', Request::getInt('tf_radio', 0));
228
		$testfieldsObj->setVar('tf_status', Request::getInt('tf_status', 0));
229
		$testfieldDatetimeArr = Request::getArray('tf_datetime');
230
		$testfieldDatetime = strtotime($testfieldDatetimeArr['date']) + (int)$testfieldDatetimeArr['time'];
231
		$testfieldsObj->setVar('tf_datetime', $testfieldDatetime);
232
		$testfieldsObj->setVar('tf_combobox', Request::getInt('tf_combobox', 0));
233
		// Insert Data
234
		if ($testfieldsHandler->insert($testfieldsObj)) {
235
			$newTfId = $testfieldsObj->getNewInsertedIdTestfields();
236
			$permId = isset($_REQUEST['tf_id']) ? $tfId : $newTfId;
237
			$grouppermHandler = xoops_getHandler('groupperm');
238
			$mid = $GLOBALS['xoopsModule']->getVar('mid');
239
			// Permission to view_testfields
240
			$grouppermHandler->deleteByModule($mid, 'mymodule3_view_testfields', $permId);
0 ignored issues
show
The method deleteByModule() does not exist on XoopsObjectHandler. Did you maybe mean delete()? ( Ignorable by Annotation )

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

240
			$grouppermHandler->/** @scrutinizer ignore-call */ 
241
                      deleteByModule($mid, 'mymodule3_view_testfields', $permId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
241
			if (isset($_POST['groups_view_testfields'])) {
242
				foreach($_POST['groups_view_testfields'] as $onegroupId) {
243
					$grouppermHandler->addRight('mymodule3_view_testfields', $permId, $onegroupId, $mid);
0 ignored issues
show
The method addRight() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

243
					$grouppermHandler->/** @scrutinizer ignore-call */ 
244
                        addRight('mymodule3_view_testfields', $permId, $onegroupId, $mid);
Loading history...
244
				}
245
			}
246
			// Permission to submit_testfields
247
			$grouppermHandler->deleteByModule($mid, 'mymodule3_submit_testfields', $permId);
248
			if (isset($_POST['groups_submit_testfields'])) {
249
				foreach($_POST['groups_submit_testfields'] as $onegroupId) {
250
					$grouppermHandler->addRight('mymodule3_submit_testfields', $permId, $onegroupId, $mid);
251
				}
252
			}
253
			// Permission to approve_testfields
254
			$grouppermHandler->deleteByModule($mid, 'mymodule3_approve_testfields', $permId);
255
			if (isset($_POST['groups_approve_testfields'])) {
256
				foreach($_POST['groups_approve_testfields'] as $onegroupId) {
257
					$grouppermHandler->addRight('mymodule3_approve_testfields', $permId, $onegroupId, $mid);
258
				}
259
			}
260
			if ('' !== $uploaderErrors) {
261
				redirect_header('testfields.php?op=edit&tf_id=' . $tfId, 5, $uploaderErrors);
262
			} else {
263
				redirect_header('testfields.php?op=list', 2, _AM_MYMODULE3_FORM_OK);
264
			}
265
		}
266
		// Get Form
267
		$GLOBALS['xoopsTpl']->assign('error', $testfieldsObj->getHtmlErrors());
268
		$form = $testfieldsObj->getFormTestfields();
269
		$GLOBALS['xoopsTpl']->assign('form', $form->render());
270
	break;
271
	case 'edit':
272
		$templateMain = 'mymodule3_admin_testfields.tpl';
273
		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('testfields.php'));
274
		$adminObject->addItemButton(_AM_MYMODULE3_ADD_TESTFIELD, 'testfields.php?op=new', 'add');
275
		$adminObject->addItemButton(_AM_MYMODULE3_TESTFIELDS_LIST, 'testfields.php', 'list');
276
		$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
277
		// Get Form
278
		$testfieldsObj = $testfieldsHandler->get($tfId);
279
		$form = $testfieldsObj->getFormTestfields();
280
		$GLOBALS['xoopsTpl']->assign('form', $form->render());
281
	break;
282
	case 'delete':
283
		$testfieldsObj = $testfieldsHandler->get($tfId);
284
		if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
285
			if (!$GLOBALS['xoopsSecurity']->check()) {
286
				redirect_header('testfields.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
287
			}
288
			if ($testfieldsHandler->delete($testfieldsObj)) {
289
				redirect_header('testfields.php', 3, _AM_MYMODULE3_FORM_DELETE_OK);
290
			} else {
291
				$GLOBALS['xoopsTpl']->assign('error', $testfieldsObj->getHtmlErrors());
292
			}
293
		} else {
294
			xoops_confirm(array('ok' => 1, 'tf_id' => $tfId, 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_AM_MYMODULE3_FORM_SURE_DELETE, $testfieldsObj->getVar('tf_text')));
295
		}
296
	break;
297
}
298
require __DIR__ . '/footer.php';
299