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/HtmlProgressbar.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\HtmlBsDoubleElement;
6
use Ajax\JsUtils;
7
8
use Ajax\bootstrap\html\base\CssRef;
9
use Ajax\service\JArray;
10
11
class HtmlProgressbar extends HtmlBsDoubleElement {
12
	protected $value;
13
	protected $max;
14
	protected $min;
15
	protected $striped="";
16
	protected $active;
17
	protected $caption;
18
	protected $isStacked=false;
19
	protected $style="";
20
	protected $styleLimits=null;
21
22
	public function __construct($identifier, $style="info", $value=0, $max=100, $min=0) {
23
		parent::__construct($identifier);
24
		$this->_template=include 'templates/tplProgressbar.php';
25
		$this->value=$value;
26
		$this->min=$min;
27
		$this->max=$max;
28
		$this->setStyle($style);
29
	}
30
31 View Code Duplication
	public function setActive($value) {
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...
32
		if(is_array($this->content)){
33
			foreach ($this->content as $pb){
34
				$pb->setActive($value);
35
			}
36
		}else{
37
			if ($value===true)
38
				$this->active="active";
39
			else
40
				$this->active="";
41
		}
42
		return $this;
43
	}
44
45
	public function setStriped($value) {
46
		if(is_array($this->content)){
47
			foreach ($this->content as $pb){
48
				$pb->setStriped($value);
49
			}
50
		}else{
51
			if ($value===true)
52
				$this->striped="progress-bar-striped";
53
			else
54
				$this->striped="";
55
		}
56
		return $this;
57
	}
58
59 View Code Duplication
	public function showCaption($value) {
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...
60
		if(is_array($this->content)){
61
			foreach ($this->content as $pb){
62
				$pb->showCaption($value);
63
			}
64
		}else{
65
			if ($value===true)
66
				$this->caption="%value%%";
67
			else
68
				$this->caption='<span class="sr-only">%value%% Complete (%style%)</span>';
69
		}
70
		return $this;
71
	}
72
73
	public function getValue() {
74
		return $this->value;
75
	}
76
77
	public function stack(HtmlProgressbar $progressBar) {
78
		$this->_template='%content%';
79
		$progressBar->setIsStacked(true);
80
		$progressBar->showCaption($this->caption=="%value%%");
81
		$progressBar->setStriped($this->striped!=="" || $progressBar->isStriped());
82
		$progressBar->setActive($this->active==="active" || $progressBar->isActive());
83
		if (is_array($this->content)===false) {
84
			$this->content=array ();
85
		}
86
		$this->content []=$progressBar;
87
	}
88
89
	public function setValue($value) {
90
		$this->value=$value;
91
		return $this;
92
	}
93
94
	public function getMax() {
95
		return $this->max;
96
	}
97
98
	public function setMax($max) {
99
		$this->max=$max;
100
		return $this;
101
	}
102
103
	public function getMin() {
104
		return $this->min;
105
	}
106
107
	public function setMin($min) {
108
		$this->min=$min;
109
		return $this;
110
	}
111
112
	public function getIsStacked() {
113
		return $this->isStacked;
114
	}
115
116
	public function setIsStacked($isStacked) {
117
		$this->isStacked=$isStacked;
118
		return $this;
119
	}
120
121
	/**
122
	 * define the progressbar style
123
	 * avaible values : "success","info","warning","danger"
124
	 * @param string|int $cssStyle
125
	 * @return \Ajax\bootstrap\html\HtmlProgressbar default : ""
126
	 */
127
	public function setStyle($cssStyle) {
128
		return $this->setMemberCtrl($this->style,CssRef::getStyle($cssStyle, "progress-bar"), CssRef::Styles("progress-bar"));
129
	}
130
131
	/*
132
	 * (non-PHPdoc)
133
	 * @see \Ajax\bootstrap\html\base\BaseHtml::compile()
134
	 */
135
	public function compile(JsUtils $js=NULL, &$view=NULL) {
136
		$actualStyle=$this->style;
137
		if(isset($this->styleLimits)&& JArray::isAssociative($this->styleLimits)){
138
			foreach ($this->styleLimits as $k=>$v){
139
				$actualStyle=$k;
140
				if($v>$this->value)
141
					break;
142
			}
143
		}
144
		$this->style=$actualStyle;
0 ignored issues
show
Documentation Bug introduced by
It seems like $actualStyle can also be of type integer. However, the property $style is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
145
		$this->_template=str_replace("%caption%", $this->caption, $this->_template);
146
		if ($this->getIsStacked()===false) {
147
			$this->wrap('<div class="progress">', '</div>');
148
		}
149
		return parent::compile($js, $view);
150
	}
151
152
	public function isStriped() {
153
		return $this->striped;
154
	}
155
156
	public function isActive() {
157
		return $this->active;
158
	}
159
160
	/* (non-PHPdoc)
161
	 * @see \Ajax\bootstrap\html\base\BaseHtml::fromDatabaseObject()
162
	 */
163
	public function fromDatabaseObject($object, $function) {
164
		$this->stack($function($object));
165
	}
166
167
	public function getStyleLimits() {
168
		return $this->styleLimits;
169
	}
170
171
	/**
172
	 * Permet de modifier le style de la progressbar à partir de sa valeur actuelle
173
	 * $styleLimits est de la forme ["success"=>50, "warning"=>100] pour obtenir un style success de 0 à 50 et warning de 50 à 100
174
	 * @param array $styleLimits tableau associatif des couples style=>valeur possibles
175
	 * @return \Ajax\bootstrap\html\HtmlProgressbar
176
	 */
177
	public function setStyleLimits($styleLimits) {
178
		$this->styleLimits=$styleLimits;
179
		return $this;
180
	}
181
182
}