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/HtmlBreadcrumbs.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
namespace Ajax\bootstrap\html;
3
4
use Ajax\bootstrap\html\base\HtmlBsDoubleElement;
5
use Ajax\bootstrap\html\HtmlLink;
6
use Ajax\JsUtils;
7
8
use Ajax\bootstrap\html\base\HtmlNavElement;
9
/**
10
 * Twitter Bootstrap Breadcrumbs component
11
 * @see http://getbootstrap.com/components/#breadcrumbs
12
 * @author jc
13
 * @version 1.001
14
 * @method _hrefFunction($e)
15
 */
16
class HtmlBreadcrumbs extends HtmlNavElement {
17
18
	/**
19
	 * @var integer the start index for href generation
20
	 */
21
	protected $startIndex=0;
22
	/**
23
	 * @var boolean $autoActive sets the last element's class to <b>active</b> if true
24
	 */
25
	protected $autoActive;
26
27
	/**
28
	 * @var boolean if set to true, the path of the elements is absolute
29
	 */
30
	protected $absolutePaths;
31
32
	/**
33
	 * @var object<Closure> the function who generates the href elements. default : function($e){return $e->getContent()}
34
	 */
35
	protected $_hrefFunction;
36
37
38
	/**
39
	 * @param string $identifier
40
	 * @param array $elements
41
	 * @param boolean $autoActive sets the last element's class to <b>active</b> if true
42
	 * @param function $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()}
43
	 */
44 View Code Duplication
	public function __construct($identifier,$elements=array(),$autoActive=true,$startIndex=0,$hrefFunction=NULL){
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...
45
		parent::__construct($identifier,"ol");
46
		$this->startIndex=$startIndex;
47
		$this->setProperty("class", "breadcrumb");
48
		$this->content=array();
49
		$this->autoActive=$autoActive;
50
		$this->absolutePaths;
51
		$this->_hrefFunction=function ($e){return $e->getContent();};
52
		if(isset($hrefFunction)){
53
			$this->_hrefFunction=$hrefFunction;
54
		}
55
		$this->addElements($elements);
56
	}
57
58
	/**
59
	 * @param mixed $element
60
	 * @param string $href
61
	 * @return \Ajax\bootstrap\html\HtmlLink
62
	 */
63
	public function addElement($element,$href="",$glyph=NULL){
64
		$size=sizeof($this->content);
65
		if(is_array($element)){
66
			$elm=new HtmlLink("lnk-".$this->identifier."-".$size);
67
			$elm->fromArray($element);
68
		}else if($element instanceof HtmlLink){
69
			$elm=$element;
70
		}else{
71
			$elm=new HtmlLink("lnk-".$this->identifier."-".$size,$href,$element);
72
			if(isset($glyph)){
73
				$elm->wrapContentWithGlyph($glyph);
74
			}
75
		}
76
		$elm->wrap("<li>","</li>");
77
		$this->content[]=$elm;
78
		$elm->setProperty($this->attr, $this->getHref($size));
79
		return $elm;
80
	}
81
82
	public function setActive($index=null){
83
		if(!isset($index)){
84
			$index=sizeof($this->content)-1;
85
		}
86
		$li=new HtmlBsDoubleElement("","li");
87
		$li->setClass("active");
88
		$li->setContent($this->content[$index]->getContent());
89
		$this->content[$index]=$li;
90
	}
91
92
	public function addElements($elements){
93
		foreach ( $elements as $element ) {
94
			$this->addElement($element);
95
		}
96
		return $this;
97
	}
98
99
	public function fromArray($array){
100
		$array=parent::fromArray($array);
101
		$this->addElements($array);
102
		return $array;
103
	}
104
105
	/**
106
	 * Return the url of the element at $index or the breadcrumbs url if $index is ommited
107
	 * @param int $index
108
	 * @param string $separator
109
	 * @return string
110
	 */
111 View Code Duplication
	public function getHref($index=null,$separator="/"){
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...
112
		if(!isset($index)){
113
			$index=sizeof($this->content);
114
		}
115
		if($this->absolutePaths===true){
116
			return $this->_hrefFunction($this->content[$index]);
117
		}else{
118
			return $this->root.implode($separator, array_slice(array_map(function($e){return $this->_hrefFunction($e);}, $this->content),$this->startIndex,$index+1));
119
		}
120
	}
121
122
	/*
123
	 * (non-PHPdoc)
124
	 * @see \Ajax\bootstrap\html\BaseHtml::compile()
125
	 */
126
	public function compile(JsUtils $js=NULL, &$view=NULL) {
127
		if($this->autoActive){
128
			$this->setActive();
129
		}
130
		return parent::compile($js, $view);
131
	}
132
133
	/* (non-PHPdoc)
134
	 * @see \Ajax\bootstrap\html\base\BaseHtml::fromDatabaseObject()
135
	 */
136
	public function fromDatabaseObject($object, $function) {
137
		return $this->addElement($function($object));
138
	}
139
140
		/*
141
	 * (non-PHPdoc)
142
	 * @see \Ajax\bootstrap\html\base\BaseHtml::on()
143
	 */
144
	public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) {
145
		foreach ($this->content as $element){
146
			$element->on($event,$jsCode,$stopPropagation,$preventDefault);
147
		}
148
		return $this;
149
	}
150
151
	public function setAutoActive($autoActive) {
152
		$this->autoActive = $autoActive;
153
		return $this;
154
	}
155
156
	public function _ajaxOn($operation, $event, $url, $responseElement="", $parameters=array()) {
157
		foreach ($this->content as $element){
158
			$element->_ajaxOn($operation, $event, $url, $responseElement, $parameters);
159
		}
160
		return $this;
161
	}
162
163
	/**
164
	 * Associate an ajax get to the breadcrumbs elements, displayed in $targetSelector
165
	 * $attr member is used to build each element url
166
	 * @param string $targetSelector the target of the get
167
	 * @return HtmlBreadcrumbs
168
	 */
169
	public function autoGetOnClick($targetSelector){
170
		return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr));
171
	}
172
173
	public function contentAsString(){
174
		if($this->autoActive){
175
			$this->setActive();
176
		}
177
		return parent::contentAsString();
178
	}
179
180
	public function getElement($index){
181
		return $this->content[$index];
182
	}
183
184
	/**
185
	 * Add a glyphicon to the element at index $index
186
	 * @param mixed $glyph
187
	 * @param int $index
188
	 */
189
	public function addGlyph($glyph,$index=0){
190
		$elm=$this->getElement($index);
191
		return $elm->wrapContentWithGlyph($glyph);
192
	}
193
194
	/**
195
	 * Add new elements in breadcrumbs corresponding to request dispatcher : controllerName, actionName, parameters
196
	 * @param JsUtils $js
197
	 * @param Dispatcher $dispatcher the request dispatcher
198
	 * @return \Ajax\bootstrap\html\HtmlBreadcrumbs
199
	 */
200
	public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0){
201
		$this->startIndex=$startIndex;
202
		return $this->addElements($js->fromDispatcher($dispatcher));
203
	}
204
205
206
	/**
207
	 * sets the function who generates the href elements. default : function($element){return $element->getContent()}
208
	 * @param function $_hrefFunction
209
	 * @return \Ajax\bootstrap\html\HtmlBreadcrumbs
210
	 */
211
	public function setHrefFunction($_hrefFunction) {
212
		$this->_hrefFunction = $_hrefFunction;
213
		return $this;
214
	}
215
216
	public function setStartIndex($startIndex) {
217
		$this->startIndex=$startIndex;
218
		return $this;
219
	}
220
221
222
}