Issues (789)

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.

app/models/BaseModel.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
3
namespace App\Models;
4
5
use Nette\Database\Context;
6
use Nette\Object;
7
use Nette\Caching\Cache;
8
9
/**
10
 * BaseModel
11
 *
12
 * Base model is a base class for all components.
13
 *
14
 * @created 2012-12-16
15
 * @author Tomas Litera <[email protected]>
16
 */
17 1
abstract class BaseModel extends Object
18
{
19
	/** @var string */
20
	protected $table = null;
21
22
	/** @var array */
23
	protected $columns = [];
24
25
	/** @var Context */
26
	protected $database;
27
28
	/** @var integer */
29
	protected $meetingId;
30
31
	/**
32
	 * @var Cache
33
	 */
34
	protected $cache;
35
36
	/** Constructor */
37
	public function __construct($table = null, $database = null)
38
	{
39
		$this->setTable($table);
40
		$this->setDatabase($database);
41
	}
42
43
	/**
44
	 * Create new or return existing instance of class
45
	 *
46
	 * @return	mixed	instance of class
47
	 */
48
	public static function getInstance()
49
	{
50
		if(self::$instance === false) {
51
			self::$instance = new self();
52
		}
53
		return self::$instance;
54
	}
55
56
	/**
57
	 * @return Nette\Database\Table\ActiveRow
58
	 */
59
	public function all()
60
	{
61
		return $this->getDatabase()
62
			->table($this->getTable())
63
			->where('deleted', '0')
64
			->fetchAll();
65
	}
66
67
	/**
68
	 * @param  integer $id
69
	 * @return Nette\Database\Table\ActiveRow
70
	 */
71
	public function find($id)
72
	{
73
		return $this->getDatabase()
74
			->table($this->getTable())
75
			->where('id ? AND deleted ?', $id, '0')
76
			->limit(1)
77
			->fetch();
78
	}
79
80
	/**
81
	 * @param  string $column
82
	 * @param  mixed  $value
83
	 * @return ActiveRow
84
	 */
85
	public function findBy($column, $value)
86
	{
87
		return $this->getDatabase()
88
			->table($this->getTable())
89
			->where($column . ' ? AND deleted ?', $value, '0')
90
			->limit(1)
91
			->fetch();
92
	}
93
94
	/**
95
	 * Create a new record
96
	 *
97
	 * @param	mixed	array of data
98
	 * @return	boolean
99
	 */
100
	public function create(array $data)
101
	{
102
		$data['guid'] = $this->generateGuid();
103
		$result = $this->getDatabase()->table($this->getTable())->insert($data);
104
105
		return $result;
106
	}
107
108
	/**
109
	 * @param	int	   $id
110
	 * @param	array  $data
111
	 * @return	bool
112
	 */
113
	public function update($id, array $data)
114
	{
115
		$result = $this->getDatabase()
116
			->table($this->getTable())
117
			->where('id', $id)
118
			->update($data);
119
120
		return $result;
121
	}
122
123
	/**
124
	 * @param	string         $column
125
	 * @param   string|integer $value
126
	 * @param	array          $data
127
	 * @return	bool
128
	 */
129
	public function updateBy($column, $value, array $data)
130
	{
131
		$result = $this->getDatabase()
132
			->table($this->getTable())
133
			->where($column, $value)
134
			->update($data);
135
136
		return $result;
137
	}
138
139
	/**
140
	 * @param	int		ID/s of record
141
	 * @return	boolean
142
	 */
143 View Code Duplication
	public function delete($ids)
0 ignored issues
show
This method seems to be duplicated in 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...
144
	{
145
		$data = [
146
			'deleted' => '1',
147
		];
148
149
		$result = $this->getDatabase()
150
			->table($this->getTable())
151
			->where('id', $ids)
152
			->update($data);
153
154
		return $result;
155
	}
156
157
	/**
158
	 * @param  integer $meetingId
159
	 * @return $this
160
	 */
161
	public function setMeetingId($meetingId)
162
	{
163 1
		$this->meetingId = $meetingId;
164
165 1
		return $this;
166
	}
167
168
	/**
169
	 * @return integer
170
	 */
171
	protected function getMeetingId()
172
	{
173 1
		return $this->meetingId;
174
	}
175
176
	/**
177
	 * @return Nette\Database\Context
178
	 */
179
	protected function getDatabase()
180
	{
181 1
		return $this->database;
182
	}
183
184
	/**
185
	 * @param  Nette\Database\Context $database
186
	 * @return $this
187
	 */
188
	protected function setDatabase(Context $database)
189
	{
190 1
		$this->database = $database;
191 1
		return $this;
192
	}
193
194
	/**
195
	 * @return string
196
	 */
197
	protected function getTable()
198
	{
199
		return $this->table;
200
	}
201
202
	/**
203
	 * @param  string $table
204
	 * @return $this
205
	 */
206
	protected function setTable($table)
207
	{
208
		$this->table = $table;
209
210
		return $this;
211
	}
212
213
	/**
214
	 * @return string
215
	 */
216
	protected function generateGuid()
217
	{
218
		return md5(uniqid());
219
	}
220
221
	/**
222
	 * @return Cache
223
	 */
224
	protected function getCache()
225
	{
226
		return $this->cache;
227
	}
228
229
	/**
230
	 * @param  Cache $cache
231
	 * @return $this
232
	 */
233
	protected function setCache(Cache $cache)
234
	{
235 1
		$this->cache = $cache;
236
237 1
		return $this;
238
	}
239
240
}
241