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/articles.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 art_id
31
$artId = Request::getInt('art_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_articles.tpl';
40
		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('articles.php'));
41
		$adminObject->addItemButton(_AM_MYMODULE2_ADD_ARTICLE, 'articles.php?op=new', 'add');
42
		$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
43
		$articlesCount = $articlesHandler->getCountArticles();
44
		$articlesAll = $articlesHandler->getAllArticles($start, $limit);
45
		$GLOBALS['xoopsTpl']->assign('articles_count', $articlesCount);
46
		$GLOBALS['xoopsTpl']->assign('mymodule2_url', MYMODULE2_URL);
47
		$GLOBALS['xoopsTpl']->assign('mymodule2_upload_url', MYMODULE2_UPLOAD_URL);
48
		// Table view articles
49
		if ($articlesCount > 0) {
50
			foreach(array_keys($articlesAll) as $i) {
51
				$article = $articlesAll[$i]->getValuesArticles();
52
				$GLOBALS['xoopsTpl']->append('articles_list', $article);
53
				unset($article);
54
			}
55
			// Display Navigation
56
			if ($articlesCount > $limit) {
57
				include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
58
				$pagenav = new \XoopsPageNav($articlesCount, $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_ARTICLES);
63
		}
64
65
	break;
66
	case 'new':
67
		$templateMain = 'mymodule2_admin_articles.tpl';
68
		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('articles.php'));
69
		$adminObject->addItemButton(_AM_MYMODULE2_ARTICLES_LIST, 'articles.php', 'list');
70
		$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
71
		// Get Form
72
		$articlesObj = $articlesHandler->create();
73
		$form = $articlesObj->getFormArticles();
74
		$GLOBALS['xoopsTpl']->assign('form', $form->render());
75
76
	break;
77
	case 'save':
78
		// Security Check
79
		if (!$GLOBALS['xoopsSecurity']->check()) {
80
			redirect_header('articles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
81
		}
82
		if (isset($artId)) {
83
			$articlesObj = $articlesHandler->get($artId);
84
		} else {
85
			$articlesObj = $articlesHandler->create();
86
		}
87
		// Set Vars
88
		$articlesObj->setVar('art_cat', Request::getInt('art_cat', 0));
89
		$articlesObj->setVar('art_title', Request::getString('art_title', ''));
90
		$articlesObj->setVar('art_descr', Request::getString('art_descr', ''));
91
		// Set Var art_img
92
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
93
		$filename       = $_FILES['art_img']['name'];
94
		$imgMimetype    = $_FILES['art_img']['type'];
95
		$imgNameDef     = Request::getString('art_title');
96
		$uploaderErrors = '';
97
		$uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_IMAGE_PATH . '/articles/', 
98
													$helper->getConfig('mimetypes_image'), 
99
													$helper->getConfig('maxsize_image'), null, null);
100
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
101
			$extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename);
102
			$imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension;
103
			$uploader->setPrefix($imgName);
104
			$uploader->fetchMedia($_POST['xoops_upload_file'][0]);
105
			if (!$uploader->upload()) {
106
				$uploaderErrors = $uploader->getErrors();
107
			} else {
108
				$savedFilename = $uploader->getSavedFileName();
109
				$maxwidth  = (int)$helper->getConfig('maxwidth_image');
110
				$maxheight = (int)$helper->getConfig('maxheight_image');
111
				if ($maxwidth > 0 && $maxheight > 0) {
112
					// Resize image
113
					$imgHandler                = new Mymodule2\Common\Resizer();
114
					$imgHandler->sourceFile    = MYMODULE2_UPLOAD_IMAGE_PATH . '/articles/' . $savedFilename;
115
					$imgHandler->endFile       = MYMODULE2_UPLOAD_IMAGE_PATH . '/articles/' . $savedFilename;
116
					$imgHandler->imageMimetype = $imgMimetype;
117
					$imgHandler->maxWidth      = $maxwidth;
118
					$imgHandler->maxHeight     = $maxheight;
119
					$result                    = $imgHandler->resizeImage();
120
				}
121
				$articlesObj->setVar('art_img', $savedFilename);
122
			}
123
		} else {
124
			if ($filename > '') {
125
				$uploaderErrors = $uploader->getErrors();
126
			}
127
			$articlesObj->setVar('art_img', Request::getString('art_img'));
128
		}
129
		$articlesObj->setVar('art_status', Request::getInt('art_status', 0));
130
		// Set Var art_file
131
		include_once XOOPS_ROOT_PATH . '/class/uploader.php';
132
		$filename       = $_FILES['art_file']['name'];
133
		$imgNameDef     = Request::getString('art_title');
134
		$uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/articles/', 
135
													$helper->getConfig('mimetypes_file'), 
136
													$helper->getConfig('maxsize_file'), null, null);
137
		if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) {
138
			$extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename);
139
			$imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension;
140
			$uploader->setPrefix($imgName);
141
			$uploader->fetchMedia($_POST['xoops_upload_file'][1]);
142
			if (!$uploader->upload()) {
143
				$errors = $uploader->getErrors();
144
			} else {
145
				$articlesObj->setVar('art_file', $uploader->getSavedFileName());
146
			}
147
		} else {
148
			if ($filename > '') {
149
				$uploaderErrors = $uploader->getErrors();
150
			}
151
			$articlesObj->setVar('art_file', Request::getString('art_file'));
152
		}
153
		$articleCreated = date_create_from_format(_SHORTDATESTRING, Request::getString('art_created'));
154
		$articlesObj->setVar('art_created', $articleCreated->getTimestamp());
155
		$articlesObj->setVar('art_submitter', Request::getInt('art_submitter', 0));
156
		// Insert Data
157
		if ($articlesHandler->insert($articlesObj)) {
158
			$newArtId = $articlesObj->getNewInsertedIdArticles();
159
			$permId = isset($_REQUEST['art_id']) ? $artId : $newArtId;
160
			$grouppermHandler = xoops_getHandler('groupperm');
161
			$mid = $GLOBALS['xoopsModule']->getVar('mid');
162
			// Permission to view_articles
163
			$grouppermHandler->deleteByModule($mid, 'mymodule2_view_articles', $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

163
			$grouppermHandler->/** @scrutinizer ignore-call */ 
164
                      deleteByModule($mid, 'mymodule2_view_articles', $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...
164
			if (isset($_POST['groups_view_articles'])) {
165
				foreach($_POST['groups_view_articles'] as $onegroupId) {
166
					$grouppermHandler->addRight('mymodule2_view_articles', $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

166
					$grouppermHandler->/** @scrutinizer ignore-call */ 
167
                        addRight('mymodule2_view_articles', $permId, $onegroupId, $mid);
Loading history...
167
				}
168
			}
169
			// Permission to submit_articles
170
			$grouppermHandler->deleteByModule($mid, 'mymodule2_submit_articles', $permId);
171
			if (isset($_POST['groups_submit_articles'])) {
172
				foreach($_POST['groups_submit_articles'] as $onegroupId) {
173
					$grouppermHandler->addRight('mymodule2_submit_articles', $permId, $onegroupId, $mid);
174
				}
175
			}
176
			// Permission to approve_articles
177
			$grouppermHandler->deleteByModule($mid, 'mymodule2_approve_articles', $permId);
178
			if (isset($_POST['groups_approve_articles'])) {
179
				foreach($_POST['groups_approve_articles'] as $onegroupId) {
180
					$grouppermHandler->addRight('mymodule2_approve_articles', $permId, $onegroupId, $mid);
181
				}
182
			}
183
			if ('' !== $uploaderErrors) {
184
				redirect_header('articles.php?op=edit&art_id=' . $artId, 5, $uploaderErrors);
185
			} else {
186
				redirect_header('articles.php?op=list', 2, _AM_MYMODULE2_FORM_OK);
187
			}
188
		}
189
		// Get Form
190
		$GLOBALS['xoopsTpl']->assign('error', $articlesObj->getHtmlErrors());
191
		$form = $articlesObj->getFormArticles();
192
		$GLOBALS['xoopsTpl']->assign('form', $form->render());
193
194
	break;
195
	case 'edit':
196
		$templateMain = 'mymodule2_admin_articles.tpl';
197
		$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('articles.php'));
198
		$adminObject->addItemButton(_AM_MYMODULE2_ADD_ARTICLE, 'articles.php?op=new', 'add');
199
		$adminObject->addItemButton(_AM_MYMODULE2_ARTICLES_LIST, 'articles.php', 'list');
200
		$GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
201
		// Get Form
202
		$articlesObj = $articlesHandler->get($artId);
203
		$form = $articlesObj->getFormArticles();
204
		$GLOBALS['xoopsTpl']->assign('form', $form->render());
205
206
	break;
207
	case 'delete':
208
		$articlesObj = $articlesHandler->get($artId);
209
		if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
210
			if (!$GLOBALS['xoopsSecurity']->check()) {
211
				redirect_header('articles.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
212
			}
213
			if ($articlesHandler->delete($articlesObj)) {
214
				redirect_header('articles.php', 3, _AM_MYMODULE2_FORM_DELETE_OK);
215
			} else {
216
				$GLOBALS['xoopsTpl']->assign('error', $articlesObj->getHtmlErrors());
217
			}
218
		} else {
219
			xoops_confirm(array('ok' => 1, 'art_id' => $artId, 'op' => 'delete'), $_SERVER['REQUEST_URI'], sprintf(_AM_MYMODULE2_FORM_SURE_DELETE, $articlesObj->getVar('art_title')));
220
		}
221
222
	break;
223
}
224
require __DIR__ . '/footer.php';
225