This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of the Deploy module for webcms2. |
||
5 | * Copyright (c) @see LICENSE |
||
6 | */ |
||
7 | |||
8 | namespace AdminModule\DeployModule; |
||
9 | |||
10 | /** |
||
11 | * Servers presenter takes care of managing production servers. |
||
12 | * |
||
13 | * @author Tomas Voslar <[email protected]> |
||
14 | */ |
||
15 | class ServersPresenter extends BasePresenter |
||
16 | { |
||
17 | /** |
||
18 | * Server instance holder. |
||
19 | * |
||
20 | * @var \WebCMS\DeployModule\Entity\Server |
||
21 | */ |
||
22 | private $server; |
||
23 | |||
24 | /** |
||
25 | * Server entity repository. |
||
26 | * |
||
27 | * @var Doctrine\ORM\EntityRepository |
||
28 | */ |
||
29 | private $repository; |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | 6 | protected function startup() |
|
35 | { |
||
36 | 6 | parent::startup(); |
|
37 | |||
38 | 6 | $this->repository = $this->em->getRepository('\WebCMS\DeployModule\Entity\Server'); |
|
39 | 6 | } |
|
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | 3 | protected function beforeRender() |
|
45 | { |
||
46 | 3 | parent::beforeRender(); |
|
47 | 3 | } |
|
48 | |||
49 | /** |
||
50 | * Renders default template with datagrid. |
||
51 | * |
||
52 | * @param int $idPage Id of the page. |
||
53 | * |
||
54 | * @return void |
||
55 | */ |
||
56 | 1 | public function renderDefault($idPage) |
|
57 | { |
||
58 | 1 | $this->reloadContent(); |
|
59 | 1 | $this->template->idPage = $idPage; |
|
0 ignored issues
–
show
|
|||
60 | 1 | } |
|
61 | |||
62 | /** |
||
63 | * Creates datagrid with servers. |
||
64 | * |
||
65 | * @param string $name Name of the datagrid. |
||
66 | * |
||
67 | * @return \Grido\Grid Datagrid object. |
||
68 | */ |
||
69 | 1 | protected function createComponentServersGrid($name) |
|
70 | { |
||
71 | 1 | $grid = $this->createGrid($this, $name, '\WebCMS\DeployModule\Entity\Server'); |
|
72 | |||
73 | 1 | $grid->addColumnText('name', 'Name')->setSortable()->setFilterText(); |
|
74 | 1 | $grid->addColumnText('path', 'Path')->setSortable()->setFilterText(); |
|
75 | 1 | $grid->addColumnText('ip', 'Ip address')->setSortable()->setFilterText(); |
|
76 | |||
77 | 1 | $grid->addActionHref("addServer", 'Edit', 'addServer', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => 'btn btn-primary ajax')); |
|
78 | 1 | $grid->addActionHref("deleteServer", 'Delete', 'deleteServer', array('idPage' => $this->actualPage->getId()))->getElementPrototype()->addAttributes(array('class' => 'btn btn-primary btn-danger')); |
|
79 | |||
80 | 1 | return $grid; |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * Display server form action. |
||
85 | * |
||
86 | * @param int $id Application's id. |
||
87 | * @param int $idPage Id of the page. |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | 4 | public function actionAddServer($id, $idPage) |
|
0 ignored issues
–
show
|
|||
92 | { |
||
93 | 4 | if (is_numeric($id)) { |
|
94 | 2 | $this->server = $this->repository->find($id); |
|
95 | 2 | } else { |
|
96 | 2 | $this->server = new \WebCMS\DeployModule\Entity\Server; |
|
97 | } |
||
98 | 4 | } |
|
99 | |||
100 | /** |
||
101 | * Render method for server form. |
||
102 | * |
||
103 | * @param int $idPage |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | 2 | public function renderAddServer($idPage) |
|
108 | { |
||
109 | 2 | $this->reloadContent(); |
|
110 | 2 | $this->template->idPage = $idPage; |
|
0 ignored issues
–
show
The property
$template is declared private in Nette\Application\UI\Control . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
111 | 2 | } |
|
112 | |||
113 | /** |
||
114 | * Creates server form component. |
||
115 | * |
||
116 | * @return \Nette\Application\UI\Form |
||
117 | */ |
||
118 | 4 | public function createComponentServerForm() |
|
119 | { |
||
120 | 4 | $form = $this->createForm(); |
|
121 | |||
122 | 4 | $form->addText('name', 'Name')->setRequired()->setAttribute('class', array('form-control')); |
|
123 | 4 | $form->addText('path', 'Path')->setRequired()->setAttribute('class', array('form-control')); |
|
124 | 4 | $form->addText('ip', 'Ip address')->setRequired()->setAttribute('class', array('form-control')); |
|
125 | |||
126 | 4 | $form->addSubmit('send', 'Save')->setAttribute('class', array('btn btn-success')); |
|
127 | 4 | $form->onSuccess[] = callback($this, 'serverFormSubmitted'); |
|
128 | |||
129 | 4 | $form->setDefaults($this->server->toArray()); |
|
130 | |||
131 | 4 | return $form; |
|
132 | } |
||
133 | |||
134 | /** |
||
135 | * Saves form data into database. |
||
136 | * |
||
137 | * @param Nette\Forms\Form $form Server form. |
||
138 | * |
||
139 | * @return void |
||
140 | */ |
||
141 | 2 | public function serverFormSubmitted($form) |
|
142 | { |
||
143 | 2 | $values = $form->getValues(); |
|
144 | |||
145 | 2 | $this->server->setName($values->name); |
|
146 | 2 | $this->server->setPath($values->path); |
|
147 | 2 | $this->server->setIp($values->ip); |
|
148 | |||
149 | 2 | $this->em->persist($this->server); |
|
150 | 2 | $this->em->flush(); |
|
151 | |||
152 | 2 | $this->flashMessage('Server has been added.', 'success'); |
|
153 | 2 | $this->forward('default', array( |
|
154 | 2 | 'idPage' => $this->actualPage->getId() |
|
155 | 2 | )); |
|
156 | } |
||
157 | |||
158 | /** |
||
159 | * Deletes server. |
||
160 | * |
||
161 | * @param int $id Server's id to remove. |
||
162 | * |
||
163 | * @return void |
||
164 | */ |
||
165 | 1 | View Code Duplication | public function actionDeleteServer($id) |
166 | { |
||
167 | 1 | $this->server = $this->repository->find($id); |
|
168 | |||
169 | 1 | $this->em->remove($this->server); |
|
170 | 1 | $this->em->flush(); |
|
171 | |||
172 | 1 | $this->flashMessage('Server has been removed.', 'success'); |
|
173 | 1 | $this->forward('default', array( |
|
174 | 1 | 'idPage' => $this->actualPage->getId() |
|
175 | 1 | )); |
|
176 | } |
||
177 | } |
||
178 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.