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/mymodule2/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 2 module for xoops
14
 *
15
 * @copyright     2020 XOOPS Project (https://xooops.org)
16
 * @license        GPL 2.0 or later
17
 * @package        mymodule2
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\Mymodule2;
25
use XoopsModules\Mymodule2\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 = 'mymodule2_admin_testfields.tpl';
40
		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('testfields.php'));
41
		$adminObject->addItemButton(_AM_MYMODULE2_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('mymodule2_url', MYMODULE2_URL);
47
		$GLOBALS['xoopsTpl']->assign('mymodule2_upload_url', MYMODULE2_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_MYMODULE2_THEREARENT_TESTFIELDS);
63
		}
64
65
	break;
66
	case 'new':
67
		$templateMain = 'mymodule2_admin_testfields.tpl';
68
		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('testfields.php'));
69
		$adminObject->addItemButton(_AM_MYMODULE2_TESTFIELDS_LIST, 'testfields.php', 'list');
70
		$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
71
		// Get Form
72
		$testfieldsObj = $testfieldsHandler->create();
73
		$form = $testfieldsObj->getFormTestfields();
74
		$GLOBALS['xoopsTpl']->assign('form', $form->render());
75
76
	break;
77
	case 'save':
78
		// Security Check
79
		if (!$GLOBALS['xoopsSecurity']->check()) {
80
			redirect_header('testfields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
81
		}
82
		if (isset($tfId)) {
83
			$testfieldsObj = $testfieldsHandler->get($tfId);
84
		} else {
85
			$testfieldsObj = $testfieldsHandler->create();
86
		}
87
		// Set Vars
88
		$testfieldsObj->setVar('tf_text', Request::getString('tf_text', ''));
89
		$testfieldsObj->setVar('tf_textarea', Request::getString('tf_textarea', ''));
90
		$testfieldsObj->setVar('tf_dhtml', Request::getString('tf_dhtml', ''));
91
		$testfieldsObj->setVar('tf_checkbox', Request::getInt('tf_checkbox', 0));
92
		$testfieldsObj->setVar('tf_yesno', Request::getInt('tf_yesno', 0));
93
		$testfieldsObj->setVar('tf_selectbox', Request::getString('tf_selectbox', ''));
94
		$testfieldsObj->setVar('tf_user', Request::getInt('tf_user', 0));
95
		$testfieldsObj->setVar('tf_color', Request::getString('tf_color', ''));
96
		// Set Var tf_imagelist
97
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
98
		$uploader = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32', 
99
													$helper->getConfig('mimetypes_image'), 
100
													$helper->getConfig('maxsize_image'), null, null);
101
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
102
			//$uploader->setPrefix(tf_imagelist_);
103
			//$uploader->fetchMedia($_POST['xoops_upload_file'][0]);
104
			if (!$uploader->upload()) {
105
				$errors = $uploader->getErrors();
106
				redirect_header('javascript:history.go(-1).php', 3, $errors);
107
			} else {
108
				$testfieldsObj->setVar('tf_imagelist', $uploader->getSavedFileName());
109
			}
110
		} else {
111
			$testfieldsObj->setVar('tf_imagelist', Request::getString('tf_imagelist'));
112
		}
113
		$testfieldsObj->setVar('tf_urlfile', formatUrl($_REQUEST['tf_urlfile']));
114
		// Set Var tf_urlfile
115
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
116
		$filename       = $_FILES['tf_urlfile']['name'];
117
		$imgNameDef     = Request::getString('tf_text');
118
		$uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', 
119
													$helper->getConfig('mimetypes_file'), 
120
													$helper->getConfig('maxsize_file'), null, null);
121
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) {
122
			$extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename);
123
			$imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension;
124
			$uploader->setPrefix($imgName);
125
			$uploader->fetchMedia($_POST['xoops_upload_file'][1]);
126
			if (!$uploader->upload()) {
127
				$errors = $uploader->getErrors();
128
			} else {
129
				$testfieldsObj->setVar('tf_urlfile', $uploader->getSavedFileName());
130
			}
131
		} else {
132
			if ($filename > '') {
133
				$uploaderErrors = $uploader->getErrors();
134
			}
135
			$testfieldsObj->setVar('tf_urlfile', Request::getString('tf_urlfile'));
136
		}
137
		// Set Var tf_uplimage
138
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
139
		$filename       = $_FILES['tf_uplimage']['name'];
140
		$imgMimetype    = $_FILES['tf_uplimage']['type'];
141
		$imgNameDef     = Request::getString('tf_text');
142
		$uploaderErrors = '';
143
		$uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/', 
144
													$helper->getConfig('mimetypes_image'), 
145
													$helper->getConfig('maxsize_image'), null, null);
146
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][2])) {
147
			$extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename);
148
			$imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension;
149
			$uploader->setPrefix($imgName);
150
			$uploader->fetchMedia($_POST['xoops_upload_file'][2]);
151
			if (!$uploader->upload()) {
152
				$uploaderErrors = $uploader->getErrors();
153
			} else {
154
				$savedFilename = $uploader->getSavedFileName();
155
				$maxwidth  = (int)$helper->getConfig('maxwidth_image');
156
				$maxheight = (int)$helper->getConfig('maxheight_image');
157
				if ($maxwidth > 0 && $maxheight > 0) {
158
					// Resize image
159
					$imgHandler                = new Mymodule2\Common\Resizer();
160
					$imgHandler->sourceFile    = MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename;
161
					$imgHandler->endFile       = MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename;
162
					$imgHandler->imageMimetype = $imgMimetype;
163
					$imgHandler->maxWidth      = $maxwidth;
164
					$imgHandler->maxHeight     = $maxheight;
165
					$result                    = $imgHandler->resizeImage();
166
				}
167
				$testfieldsObj->setVar('tf_uplimage', $savedFilename);
168
			}
169
		} else {
170
			if ($filename > '') {
171
				$uploaderErrors = $uploader->getErrors();
172
			}
173
			$testfieldsObj->setVar('tf_uplimage', Request::getString('tf_uplimage'));
174
		}
175
		// Set Var tf_uplfile
176
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
177
		$filename       = $_FILES['tf_uplfile']['name'];
178
		$imgNameDef     = Request::getString('tf_text');
179
		$uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', 
180
													$helper->getConfig('mimetypes_file'), 
181
													$helper->getConfig('maxsize_file'), null, null);
182
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][3])) {
183
			$extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename);
184
			$imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension;
185
			$uploader->setPrefix($imgName);
186
			$uploader->fetchMedia($_POST['xoops_upload_file'][3]);
187
			if (!$uploader->upload()) {
188
				$errors = $uploader->getErrors();
189
			} else {
190
				$testfieldsObj->setVar('tf_uplfile', $uploader->getSavedFileName());
191
			}
192
		} else {
193
			if ($filename > '') {
194
				$uploaderErrors = $uploader->getErrors();
195
			}
196
			$testfieldsObj->setVar('tf_uplfile', Request::getString('tf_uplfile'));
197
		}
198
		$testfieldTextdateselect = date_create_from_format(_SHORTDATESTRING, Request::getString('tf_textdateselect'));
199
		$testfieldsObj->setVar('tf_textdateselect', $testfieldTextdateselect->getTimestamp());
200
		// Set Var tf_selectfile
201
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
202
		$filename       = $_FILES['tf_selectfile']['name'];
203
		$imgNameDef     = Request::getString('tf_text');
204
		$uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', 
205
													$helper->getConfig('mimetypes_file'), 
206
													$helper->getConfig('maxsize_file'), null, null);
207
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][4])) {
208
			$extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename);
209
			$imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension;
210
			$uploader->setPrefix($imgName);
211
			$uploader->fetchMedia($_POST['xoops_upload_file'][4]);
212
			if (!$uploader->upload()) {
213
				$errors = $uploader->getErrors();
214
			} else {
215
				$testfieldsObj->setVar('tf_selectfile', $uploader->getSavedFileName());
216
			}
217
		} else {
218
			if ($filename > '') {
219
				$uploaderErrors = $uploader->getErrors();
220
			}
221
			$testfieldsObj->setVar('tf_selectfile', Request::getString('tf_selectfile'));
222
		}
223
		$testfieldsObj->setVar('tf_status', Request::getInt('tf_status', 0));
224
		// Insert Data
225
		if ($testfieldsHandler->insert($testfieldsObj)) {
226
			$newTfId = $testfieldsObj->getNewInsertedIdTestfields();
227
			$permId = isset($_REQUEST['tf_id']) ? $tfId : $newTfId;
228
			$grouppermHandler = xoops_getHandler('groupperm');
229
			$mid = $GLOBALS['xoopsModule']->getVar('mid');
230
			// Permission to view_testfields
231
			$grouppermHandler->deleteByModule($mid, 'mymodule2_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

231
			$grouppermHandler->/** @scrutinizer ignore-call */ 
232
                      deleteByModule($mid, 'mymodule2_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...
232
			if (isset($_POST['groups_view_testfields'])) {
233
				foreach($_POST['groups_view_testfields'] as $onegroupId) {
234
					$grouppermHandler->addRight('mymodule2_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

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