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/HtmlButtongroups.php (3 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
use Ajax\bootstrap\html\base\CssRef;
6
use Ajax\bootstrap\html\base\HtmlBsDoubleElement;
7
8
/**
9
 * Twitter Bootstrap Buttongroups component
10
 * @see http://getbootstrap.com/components/#btn-groups
11
 * @author jc
12
 * @version 1.001
13
 */
14
class HtmlButtongroups extends HtmlBsDoubleElement {
15
	protected $elements;
16
17 View Code Duplication
	public function __construct($identifier, $elements=array(), $cssStyle=NULL, $size=NULL, $tagName="div") {
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...
18
		parent::__construct($identifier, $tagName);
19
		$this->_template="<%tagName% id='%identifier%' %properties%>%elements%</%tagName%>";
20
		$this->setProperty("class", "btn-group");
21
		$this->setRole("group");
22
		$this->addElements($elements);
23
		if (isset($cssStyle)) {
24
			$this->setStyle($cssStyle);
25
		}
26
		if (isset($size)) {
27
			$this->setSize($size);
28
		}
29
	}
30
31
	/**
32
	 * define the buttons size
33
	 * available values : "btn-group-lg","","btn-group-sm","btn-group-xs"
34
	 * @param string|int $size
35
	 * @return HtmlButtongroups default : ""
36
	 */
37
	public function setSize($size) {
38
		foreach ( $this->elements as $element ) {
39
			$element->setSize($size);
40
		}
41 View Code Duplication
		if (is_int($size)) {
0 ignored issues
show
This code seems to be duplicated across 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...
42
			return $this->addToPropertyUnique("class", CssRef::sizes("btn-group")[$size], CssRef::sizes("btn-group"));
43
		}
44
		return $this->addToPropertyCtrl("class", $size, CssRef::sizes("btn-group"));
45
	}
46
47
	public function setStyle($value) {
48
		foreach ( $this->elements as $element )
49
			$element->setStyle($value);
50
	}
51
52
	private function dropdownAsButton($bt) {
53
		$this->addExistingDropDown($bt);
54
		$bt->setTagName("button");
55
		$bt->addBtnClass("dropdown-toogle");
56
		$bt->addBtnClass("btn-default");
57
	}
58
59
	private function addExistingDropDown($bt) {
60
		$bt->setMTagName("div");
61
		$bt->setRole("group");
62
		$bt->setMClass("btn-group");
63
	}
64
65
	public function addElement($element) {
66
		$result=$element;
67
		$iid=sizeof($this->elements)+1;
68
		if (($element instanceof HtmlDropdown)||($element instanceof HtmlSplitbutton)) {
69
			$this->addExistingDropDown($element);
70
			$this->elements[]=$element;
71
		} elseif ($element instanceof HtmlButton) {
72
			$this->elements[]=$element;
73
		} elseif (is_array($element)) {
74
			if (array_key_exists("glyph", $element))
75
				$bt=new HtmlGlyphButton($this->identifier."-button-".$iid);
76
			elseif (array_key_exists("btnCaption", $element)) {
77
				if (array_key_exists("split", $element))
78
					$bt=new HtmlSplitbutton($this->identifier."-dropdown-".$iid);
79
				else
80
					$bt=new HtmlDropdown($this->identifier."-dropdown-".$iid);
81
				$this->dropdownAsButton($bt);
82
			} else
83
				$bt=new HtmlButton($this->identifier."-button-".$iid);
84
			$bt->fromArray($element);
85
			$this->elements[]=$bt;
86
			$result=$bt;
87
		} elseif (is_string($element)) {
88
			$bt=new HtmlButton($this->identifier."-button-".$iid);
89
			$bt->setValue($element);
90
			$this->elements[]=$bt;
91
			$result=$bt;
92
		}
93
		return $result;
94
	}
95
96
	public function addElements($elements) {
97
		foreach ( $elements as $element ) {
98
			$this->addElement($element);
99
		}
100
		return $this;
101
	}
102
103
	/*
104
	 * (non-PHPdoc)
105
	 * @see \Ajax\bootstrap\html\HtmlSingleElement::fromArray()
106
	 */
107
	public function fromArray($array) {
108
		$this->addElements($array);
109
	}
110
111
	public function setAlignment($value) {
112
		if (is_int($value)) {
113
			$value=CssRef::alignment("btn-group")[$value];
114
		} else
115
			$value="btn-group-".$value;
116
		if (strstr($value, "justified")) {
117
			foreach ( $this->elements as $element ) {
118
				$element->wrap('<div class="btn-group" role="group">', '</div>');
119
			}
120
		}
121
		$this->addToPropertyCtrl("class", $value, CssRef::alignment("btn-group-"));
122
	}
123
124
	/**
125
	 * Return the element at index
126
	 * @param int $index
127
	 * @return HtmlButton
128
	 */
129
	public function getElement($index) {
130
		if (is_int($index))
131
			return $this->elements[$index];
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->elements[$index]; of type Ajax\bootstrap\html\Html...p\html\HtmlButtongroups adds the type Ajax\bootstrap\html\HtmlButtongroups to the return on line 131 which is incompatible with the return type documented by Ajax\bootstrap\html\HtmlButtongroups::getElement of type Ajax\bootstrap\html\HtmlButton.
Loading history...
132
		else {
133
			$elm=$this->getElementById($index, $this->elements);
134
			return $elm;
135
		}
136
	}
137
138
	public function setElement($index, $button) {
139
		$this->elements[$index]=$button;
140
		return $this;
141
	}
142
143
	/*
144
	 * (non-PHPdoc)
145
	 * @see \Ajax\bootstrap\html\base\BaseHtml::on()
146
	 */
147
	public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
148
		foreach ( $this->elements as $element ) {
149
			$element->on($event, $jsCode, $stopPropagation, $preventDefault);
150
		}
151
		return $this;
152
	}
153
154
	public function getElements() {
155
		return $this->elements;
156
	}
157
158
	/* (non-PHPdoc)
159
	 * @see \Ajax\bootstrap\html\base\BaseHtml::fromDatabaseObject()
160
	 */
161
	public function fromDatabaseObject($object, $function) {
162
		$this->addElement($function($object));
163
	}
164
165
}