Issues (277)

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.

Ajax/bootstrap/html/HtmlModal.php (2 issues)

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 Ajax\bootstrap\html;
4
5
6
use Ajax\JsUtils;
7
use Ajax\common\html\BaseHtml;
8
9
/**
10
 * Twitter Bootstrap HTML Modal component
11
 * @author jc
12
 * @version 1.001
13
 */
14
class HtmlModal extends BaseHtml {
15
	protected $title="Titre de ma boƮte";
16
	protected $content="";
17
	protected $buttons=array ();
18
	protected $showOnStartup=false;
19
	protected $draggable=false;
20
	protected $validCondition=NULL;
21
	protected $backdrop=true;
22
23
	/**
24
	 *
25
	 * @param string $identifier the id
26
	 */
27
	public function __construct($identifier, $title="", $content="", $buttonCaptions=array()) {
28
		parent::__construct($identifier);
29
		$this->_template=include 'templates/tplModal.php';
30
		$this->buttons=array ();
31
		$this->title=$title;
32
		$this->content=$content;
33
		foreach ( $buttonCaptions as $button ) {
34
			$this->addButton($button);
35
		}
36
	}
37
38
	/**
39
	 * Add a button
40
	 * @param string $value the button caption
41
	 * @param string $style one of "btn-default","btn-primary","btn-success","btn-info","btn-warning","btn-danger"
42
	 * @return HtmlButton
43
	 */
44
	public function addButton($value="Okay", $style="btn-primary") {
45
		$btn=new HtmlButton($this->identifier."-".$value);
46
		$btn->setStyle($style);
47
		$btn->setValue($value);
48
		$this->buttons []=$btn;
49
		return $btn;
50
	}
51
52
	/**
53
	 * Add a cancel button (dismiss)
54
	 * @param string $value
55
	 * @return HtmlButton
56
	 */
57
	public function addCancelButton($value="Annuler") {
58
		$btn=$this->addButton($value, "btn-default");
59
		$btn->setProperty("data-dismiss", "modal");
60
		return $btn;
61
	}
62
63
	/**
64
	 * Add an Okay button (close the box only if $(identifier).valid===true)
65
	 * @param string $value
66
	 * @return HtmlButton
67
	 */
68
	public function addOkayButton($value="Okay",$jsCode="") {
69
		$btn=$this->addButton($value, "btn-primary");
70
		$btn->onClick("if(".$this->getValidCondition()."){ ".$jsCode."$('#".$this->identifier."').modal('hide');}");
71
		return $btn;
72
	}
73
74
	protected function getDefaultValidCondition() {
75
		return "$('#".$this->identifier."').prop('valid')";
76
	}
77
78
	public function setValidCondition($js) {
79
		$this->validCondition=$js;
80
	}
81
82
	public function getValidCondition() {
83
		if ($this->validCondition==NULL) {
84
			return $this->getDefaultValidCondition();
85
		} else {
86
			return $this->validCondition;
87
		}
88
	}
89
90
	public function setValid() {
91
		$this->validCondition="1==1";
92
	}
93
94
	/**
95
	 * set the content of the modal
96
	 * @param string $content
97
	 */
98
	public function setContent($content) {
99
		$this->content=$content;
100
	}
101
102
	/**
103
	 * set the title of the modal
104
	 * @param string $title
105
	 */
106
	public function setTitle($title) {
107
		$this->title=$title;
108
	}
109
110
	/**
111
	 * render the content of an existing view : $controller/$action and set the response to the modal content
112
	 * @param JsUtils $js
113
	 * @param Controller $initialController
114
	 * @param string $viewName
115
	 * @param $params The parameters to pass to the view
116
	 */
117
	public function renderView(JsUtils $js,$initialController,$viewName, $params=array()) {
118
		$this->content=$js->renderContent($initialController, $viewName,$params);
0 ignored issues
show
$viewName is of type string, but the function expects a object<Ajax\view>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
119
	}
120
121
	/**
122
	 * render the content of $controller::$action and set the response to the modal content
123
	 * @param JsUtils $js
124
	 * @param string $title The panel title
0 ignored issues
show
There is no parameter named $title. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
125
	 * @param Controller $initialControllerInstance
126
	 * @param string $controllerName the controller name
127
	 * @param string $actionName the action name
128
	 */
129
	public function forward(JsUtils $js,$initialControllerInstance,$controllerName,$actionName,$params=NULL){
130
		$this->content=$js->forward($initialControllerInstance, $controllerName, $actionName,$params);
131
	}
132
133
	/*
134
	 * (non-PHPdoc)
135
	 * @see BaseHtml::run()
136
	 */
137
	public function run(JsUtils $js) {
138
		if($this->content instanceof BaseHtml){
139
			$this->content->run($js);
140
		}
141
		$this->_bsComponent=$js->bootstrap()->modal("#".$this->identifier, array (
142
				"show" => $this->showOnStartup
143
		));
144
		if ($this->draggable)
145
			$this->_bsComponent->setDraggable(true);
146
		$this->_bsComponent->setBackdrop($this->backdrop);
147
		$this->addEventsOnRun($js);
148
		return $this->_bsComponent;
149
	}
150
151
	public function getButton($index) {
152
		if (is_int($index))
153
			return $this->buttons [$index];
154
		else
155
			return $this->getElementById($index, $this->buttons);
156
	}
157
158
	public function showOnCreate() {
159
		$this->showOnStartup=true;
160
		return $this;
161
	}
162
163
	public function jsShow() {
164
		return "$('#{$this->identifier}').modal('show');";
165
	}
166
167
	public function jsHide() {
168
		return "$('#{$this->identifier}').modal('hide');";
169
	}
170
171
	public function jsGetContent(JsUtils $js, $url) {
172
		return $js->getDeferred($url, "#".$this->identifier." .modal-body");
173
	}
174
175
	public function jsSetTitle($title) {
176
		return "$('#".$this->identifier." .modal-title').html('".$title."');";
177
	}
178
179
	public function jsHideButton($index) {
180
		$btn=$this->getButton($index);
181
		if ($btn)
182
			return "$('#".$btn->getIdentifier()."').hide();";
183
	}
184
185
	/**
186
	 * Allow modal to be moved using the mouse.
187
	 * needs JQuery UI
188
	 * @param boolean $value
189
	 */
190
	public function setDraggable($value) {
191
		$this->draggable=$value;
192
		if ($value) {
193
			$this->backdrop=false;
194
		}
195
	}
196
197
	/**
198
	 * Includes a modal-backdrop element.
199
	 * Alternatively, specify static for a backdrop which doesn't close the modal on click.
200
	 * @param Boolean $value default : true
201
	 * @return HtmlModal
202
	 */
203
	public function setBackdrop($value) {
204
		return $this->backdrop=$value;
205
	}
206
}