Issues (201)

Security Analysis    no request data  

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.

includes/Admin/View/UserTable.php (1 issue)

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
namespace Redaxscript\Admin\View;
3
4
use Redaxscript\Admin;
5
use Redaxscript\Dater;
6
use Redaxscript\Html;
7
use Redaxscript\Module;
8
use function count;
9
use function json_decode;
10
11
/**
12
 * children class to create the admin user table
13
 *
14
 * @since 4.0.0
15
 *
16
 * @package Redaxscript
17
 * @category View
18
 * @author Henry Ruhs
19
 */
20
21
class UserTable extends ViewAbstract
22
{
23
	/**
24
	 * render the view
25
	 *
26
	 * @since 4.0.0
27
	 *
28
	 * @return string
29
	 */
30
31 4
	public function render() : string
32
	{
33 4
		$output = Module\Hook::trigger('adminUserTableStart');
34 4
		$parameterRoute = $this->_registry->get('parameterRoute');
35 4
		$usersNew = $this->_registry->get('usersNew');
36
37
		/* html element */
38
39 4
		$element = new Html\Element();
40
		$titleElement = $element
41 4
			->copy()
42 4
			->init('h2',
43
			[
44 4
				'class' => 'rs-admin-title-content',
45
			])
46 4
			->text($this->_language->get('users'));
47
		$linkElement = $element
48 4
			->copy()
49 4
			->init('a',
50
			[
51 4
				'class' => 'rs-admin-button-default rs-admin-button-create',
52 4
				'href' => $parameterRoute . 'admin/new/users'
53
			])
54 4
			->text($this->_language->get('user_new'));
55
56
		/* collect output */
57
58 4
		$output .= $titleElement;
59 4
		if ($usersNew)
60
		{
61 1
			$output .= $linkElement;
62
		}
63 4
		$output .= $this->_renderTable();
64 4
		$output .= Module\Hook::trigger('adminUserTableEnd');
65 4
		return $output;
66
	}
67
68
	/**
69
	 * render the table
70
	 *
71
	 * @since 4.0.0
72
	 *
73
	 * @return string|null
74
	 */
75
76 4
	protected function _renderTable() : ?string
77
	{
78 4
		$output = null;
79 4
		$outputHead = null;
80 4
		$outputBody = null;
81 4
		$outputFoot = null;
82
		$tableArray =
83
		[
84 4
			'name' => $this->_language->get('name'),
85 4
			'user' => $this->_language->get('user'),
86 4
			'session' => $this->_language->get('session'),
87 4
			'groups' => $this->_language->get('groups')
88
		];
89 4
		$adminControl = new Helper\Control($this->_registry, $this->_language);
90 4
		$adminControl->init();
91 4
		$userModel = new Admin\Model\User();
92 4
		$users = $userModel->getAll();
93 4
		$usersTotal = $users->count();
94
95
		/* html element */
96
97 4
		$element = new Html\Element();
98
		$wrapperElement = $element
99 4
			->copy()
100 4
			->init('div',
101
			[
102 4
				'class' => 'rs-admin-wrapper-table'
103
			]);
104
		$tableElement = $element
105 4
			->copy()
106 4
			->init('table',
107
			[
108 4
				'class' => 'rs-admin-table-default rs-admin-table-user'
109
			]);
110 4
		$theadElement = $element->copy()->init('thead');
111 4
		$tbodyElement = $element->copy()->init('tbody');
112 4
		$tfootElement = $element->copy()->init('tfoot');
113 4
		$trElement = $element->copy()->init('tr');
114 4
		$thElement = $element->copy()->init('th');
115 4
		$tdElement = $element->copy()->init('td');
116
117
		/* process table */
118
119 4
		foreach ($tableArray as $key => $value)
120
		{
121 4
			$outputHead .= $thElement->copy()->text($value);
122 4
			$outputFoot .= $tdElement->copy()->text($value);
123
		}
124
125
		/* process categories */
126
127 4
		if ($usersTotal)
128
		{
129 4
			foreach ($users as $key => $value)
130
			{
131
				$outputBody .= $trElement
132 4
					->copy()
133 4
					->attr('id', 'row-' . $value->id)
134 4
					->addClass(!$value->status ? 'rs-admin-is-disabled' : null)
135 4
					->html(
136 4
						$tdElement->copy()->html($value->name . $adminControl->render('users', $value->id, $value->alias, $value->status)) .
137 4
						$tdElement->copy()->text($value->user) .
138 4
						$tdElement->copy()->text($this->_renderSession($value->last)) .
139 4
						$tdElement->copy()->html($this->_renderGroup($value->groups))
140
					);
141
			}
142
		}
143
		else
144
		{
145
			$outputBody .= $trElement
146
				->copy()
147
				->html(
148
					$tdElement
149
						->copy()
150
						->attr('colspan', count($tableArray))
151
						->text($this->_language->get('user_no'))
152
				);
153
		}
154
155
		/* collect output */
156
157 4
		$outputHead = $theadElement->html(
158 4
			$trElement->html($outputHead)
159
		);
160 4
		$outputBody = $tbodyElement->html($outputBody);
161 4
		$outputFoot = $tfootElement->html(
162 4
			$trElement->html($outputFoot)
163
		);
164 4
		$output .= $wrapperElement->copy()->html(
165 4
			$tableElement->html($outputHead . $outputBody . $outputFoot)
166
		);
167 4
		return $output;
168
	}
169
170
	/**
171
	 * render the session
172
	 *
173
	 * @since 4.0.0
174
	 *
175
	 * @param string $last
176
	 *
177
	 * @return string
178
	 */
179
180 4
	protected function _renderSession(string $last = null) : string
181
	{
182 4
		$daterLast = new Dater();
183 4
		$daterLast->init($last);
184 4
		$daterNow = new Dater();
185 4
		$daterNow->init($this->_registry->get('now'));
186
187
		/* handle session */
188
189 4
		if (!$last)
0 ignored issues
show
Bug Best Practice introduced by
The expression $last of type null|string is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
190
		{
191
			return $this->_language->get('session_no');
192
		}
193 4
		if ($daterLast->getDateTime() > $daterNow->getDateTime()->modify('-1 minute'))
194
		{
195 2
			return $this->_language->get('online');
196
		}
197 2
		if ($daterLast->getDateTime() > $daterNow->getDateTime()->modify('+1 minute -1 day'))
198
		{
199 1
			return $this->_language->get('today') . ' ' . $this->_language->get('at') . ' ' . $daterLast->formatTime();
200
		}
201 1
		return $daterLast->formatDate();
202
	}
203
204
	/**
205
	 * render the group
206
	 *
207
	 * @since 4.0.0
208
	 *
209
	 * @param string groups
210
	 *
211
	 * @return string|null
212
	 */
213
214 4
	protected function _renderGroup(string $groups = null) : ?string
215
	{
216 4
		$output = null;
217 4
		$groupModel = new Admin\Model\Group();
218 4
		$groupArray = (array)json_decode($groups);
219
220
		/* html element */
221
222 4
		$linkElement = new Html\Element();
223 4
		$linkElement->init('a');
224
225
		/* process groups */
226
227 4
		if ($groupArray)
228
		{
229 4
			foreach ($groupArray as $groupId)
230
			{
231
				$output .= $linkElement
232 4
					->copy()
233 4
					->attr('href', $this->_registry->get('parameterRoute') . 'admin/edit/groups/' . $groupId)
234 4
					->text($groupModel->getById($groupId)->name);
235
			}
236
		}
237
		else
238
		{
239
			$output = $this->_language->get('none');
240
		}
241 4
		return $output;
242
	}
243
}
244