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 | * Pagination Class. Adapted from http://www.mis-algoritmos.com/2007/05/27/digg-style-pagination-class/ |
|||||||||||
4 | * Original author: Victor De la Rocha |
|||||||||||
5 | * Date: 28/11/2015 |
|||||||||||
6 | */ |
|||||||||||
7 | if ( ! class_exists( 'FooGalleryNextGenPagination' ) ) { |
|||||||||||
8 | ||||||||||||
9 | class FooGalleryNextGenPagination { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
10 | ||||||||||||
11 | /* Default values */ |
|||||||||||
12 | var $item_count = 100; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$item_count .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
13 | var $limit = 10; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$limit .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
14 | var $target = ""; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$target .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
15 | var $page = 1; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$page .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
16 | var $adjacents = 2; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$adjacents .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
17 | var $parameterName = "paged"; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$parameterName .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
18 | var $urlF = false;//urlFriendly |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$urlF .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
19 | var $start = -1; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$start .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
20 | var $end = -1; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$end .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
21 | var $page_count = 10; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$page_count .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
22 | var $url = false; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$url .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
23 | ||||||||||||
24 | /* Next and previous buttons */ |
|||||||||||
25 | var $nextI = "›"; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$nextI .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
26 | var $prevI = "‹"; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$prevI .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
27 | ||||||||||||
28 | /* Processing variables */ |
|||||||||||
29 | var $calculate = false; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$calculate .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
30 | var $pagination = ''; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$pagination .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
31 | var $errors = false; |
|||||||||||
0 ignored issues
–
show
The visibility should be declared for property
$errors .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
||||||||||||
32 | ||||||||||||
33 | #Total items |
|||||||||||
34 | function items( $value ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
35 | $this->item_count = (int) $value; |
|||||||||||
36 | } |
|||||||||||
37 | ||||||||||||
38 | #how many items to show per page |
|||||||||||
39 | function limit( $value ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
40 | $this->limit = (int) $value; |
|||||||||||
41 | } |
|||||||||||
42 | ||||||||||||
43 | #Page to sent the page value |
|||||||||||
44 | function target( $value ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
45 | $this->target = $value; |
|||||||||||
46 | } |
|||||||||||
47 | ||||||||||||
48 | #Current page |
|||||||||||
49 | function currentPage( $value ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
50 | $this->page = (int) $value; |
|||||||||||
51 | } |
|||||||||||
52 | ||||||||||||
53 | #How many adjacent pages should be shown on each side of the current page? |
|||||||||||
54 | function adjacents( $value ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
55 | $this->adjacents = (int) $value; |
|||||||||||
56 | } |
|||||||||||
57 | ||||||||||||
58 | #show counter? |
|||||||||||
59 | function showCounter( $value = "" ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
60 | $this->showCounter = ( $value === true ) ? true : false; |
|||||||||||
0 ignored issues
–
show
The property
showCounter does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
||||||||||||
61 | } |
|||||||||||
62 | ||||||||||||
63 | #to change the class name of the pagination div |
|||||||||||
64 | function changeClass( $value = "" ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
65 | $this->className = $value; |
|||||||||||
0 ignored issues
–
show
The property
className does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
||||||||||||
66 | } |
|||||||||||
67 | ||||||||||||
68 | function nextLabel( $value ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
69 | $this->nextT = $value; |
|||||||||||
0 ignored issues
–
show
The property
nextT does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
||||||||||||
70 | } |
|||||||||||
71 | ||||||||||||
72 | function nextIcon( $value ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
73 | $this->nextI = $value; |
|||||||||||
74 | } |
|||||||||||
75 | ||||||||||||
76 | function prevLabel( $value ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
77 | $this->prevT = $value; |
|||||||||||
0 ignored issues
–
show
The property
prevT does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
||||||||||||
78 | } |
|||||||||||
79 | ||||||||||||
80 | function prevIcon( $value ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
81 | $this->prevI = $value; |
|||||||||||
82 | } |
|||||||||||
83 | ||||||||||||
84 | #to change the class name of the pagination div |
|||||||||||
85 | function parameterName( $value = "" ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
86 | $this->parameterName = $value; |
|||||||||||
87 | } |
|||||||||||
88 | ||||||||||||
89 | function render($echo = true) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
90 | if ( ! $this->calculate ) { |
|||||||||||
91 | $this->calculate(); |
|||||||||||
92 | } |
|||||||||||
93 | if ( $echo ) { |
|||||||||||
94 | echo $this->pagination; |
|||||||||||
95 | } else { |
|||||||||||
96 | return $this->pagination; |
|||||||||||
97 | } |
|||||||||||
98 | } |
|||||||||||
99 | ||||||||||||
100 | function get_page_number_url( $page_number ) { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
101 | return esc_url( add_query_arg( $this->parameterName, $page_number, $this->url ) ); |
|||||||||||
102 | } |
|||||||||||
103 | ||||||||||||
104 | function calculate() { |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
105 | $this->pagination = ""; |
|||||||||||
106 | $this->calculate = true; |
|||||||||||
107 | $this->errors = false; |
|||||||||||
108 | ||||||||||||
109 | if ( $this->urlF and $this->urlF != '%' and strpos( $this->target, $this->urlF ) === false ) { |
|||||||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Using logical operators such as
and instead of && is generally not recommended.
PHP has two types of connecting operators (logical operators, and boolean operators):
The difference between these is the order in which they are executed. In most cases,
you would want to use a boolean operator like Let’s take a look at a few examples: // Logical operators have lower precedence:
$f = false or true;
// is executed like this:
($f = false) or true;
// Boolean operators have higher precedence:
$f = false || true;
// is executed like this:
$f = (false || true);
Logical Operators are used for Control-FlowOne case where you explicitly want to use logical operators is for control-flow such as this: $x === 5
or die('$x must be 5.');
// Instead of
if ($x !== 5) {
die('$x must be 5.');
}
Since // The following is currently a parse error.
$x === 5
or throw new RuntimeException('$x must be 5.');
These limitations lead to logical operators rarely being of use in current PHP code. ![]() |
||||||||||||
110 | //Es necesario especificar el comodin para sustituir |
|||||||||||
111 | $this->errors = "Especificaste un wildcard para sustituir, pero no existe en el target"; |
|||||||||||
0 ignored issues
–
show
The property
$errors was declared of type boolean , but 'Especificaste un wildca...no existe en el target' is of type string . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
![]() |
||||||||||||
112 | return; |
|||||||||||
113 | } elseif ( $this->urlF and $this->urlF == '%' and strpos( $this->target, $this->urlF ) === false ) { |
|||||||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Using logical operators such as
and instead of && is generally not recommended.
PHP has two types of connecting operators (logical operators, and boolean operators):
The difference between these is the order in which they are executed. In most cases,
you would want to use a boolean operator like Let’s take a look at a few examples: // Logical operators have lower precedence:
$f = false or true;
// is executed like this:
($f = false) or true;
// Boolean operators have higher precedence:
$f = false || true;
// is executed like this:
$f = (false || true);
Logical Operators are used for Control-FlowOne case where you explicitly want to use logical operators is for control-flow such as this: $x === 5
or die('$x must be 5.');
// Instead of
if ($x !== 5) {
die('$x must be 5.');
}
Since // The following is currently a parse error.
$x === 5
or throw new RuntimeException('$x must be 5.');
These limitations lead to logical operators rarely being of use in current PHP code. ![]() |
||||||||||||
114 | $this->errors = "Es necesario especificar en el target el comodin % para sustituir el n�mero de p�gina"; |
|||||||||||
0 ignored issues
–
show
The property
$errors was declared of type boolean , but 'Es necesario especifica...l n�mero de p�gina' is of type string . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
![]() |
||||||||||||
115 | return; |
|||||||||||
116 | } |
|||||||||||
117 | ||||||||||||
118 | $n = $this->nextI; |
|||||||||||
119 | $p = $this->prevI; |
|||||||||||
120 | ||||||||||||
121 | /* Setup vars for query. */ |
|||||||||||
122 | if ( $this->page ) { |
|||||||||||
123 | $this->start = ( $this->page - 1 ) * $this->limit; //first item to display on this page |
|||||||||||
124 | $this->end = $this->start + $this->limit - 1; |
|||||||||||
125 | } else { |
|||||||||||
126 | $this->start = 0; //if no page var is given, set start to 0 |
|||||||||||
127 | $this->end = $this->limit - 1; |
|||||||||||
128 | } |
|||||||||||
129 | ||||||||||||
130 | /* Setup page vars for display. */ |
|||||||||||
131 | $counter = 1; |
|||||||||||
132 | $prev = $this->page - 1; //previous page is page - 1 |
|||||||||||
133 | $next = $this->page + 1; //next page is page + 1 |
|||||||||||
134 | $this->page_count = ceil( $this->item_count / $this->limit ); //lastpage is = total pages / items per page, rounded up. |
|||||||||||
0 ignored issues
–
show
The property
$page_count was declared of type integer , but ceil($this->item_count / $this->limit) is of type double . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
![]() |
||||||||||||
135 | $lpm1 = $this->page_count - 1; //last page minus 1 |
|||||||||||
136 | ||||||||||||
137 | /* |
|||||||||||
138 | Now we apply our rules and draw the pagination object. |
|||||||||||
139 | We're actually saving the code to a variable in case we want to draw it more than once. |
|||||||||||
140 | */ |
|||||||||||
141 | ||||||||||||
142 | if ( $this->page_count > 1 ) { |
|||||||||||
143 | if ( $this->page ) { |
|||||||||||
144 | //anterior button |
|||||||||||
145 | if ( $this->page > 1 ) { |
|||||||||||
146 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( $prev ) . "\" class=\"prev\">$p</a>"; |
|||||||||||
147 | } else { |
|||||||||||
148 | $this->pagination .= "<span class=\"disabled\">$p</span>"; |
|||||||||||
149 | } |
|||||||||||
150 | } |
|||||||||||
151 | //pages |
|||||||||||
152 | if ( $this->page_count < 7 + ( $this->adjacents * 2 ) ) {//not enough pages to bother breaking it up |
|||||||||||
153 | for ( $counter = 1; $counter <= $this->page_count; $counter ++ ) { |
|||||||||||
154 | if ( $counter == $this->page ) { |
|||||||||||
155 | $this->pagination .= "<span class=\"selected-page\">$counter</span>"; |
|||||||||||
156 | } else { |
|||||||||||
157 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( $counter ) . "\">$counter</a>"; |
|||||||||||
158 | } |
|||||||||||
159 | } |
|||||||||||
160 | } elseif ( $this->page_count > 5 + ( $this->adjacents * 2 ) ) {//enough pages to hide some |
|||||||||||
161 | //close to beginning; only hide later pages |
|||||||||||
162 | if ( $this->page < 1 + ( $this->adjacents * 2 ) ) { |
|||||||||||
163 | for ( $counter = 1; $counter < 4 + ( $this->adjacents * 2 ); $counter ++ ) { |
|||||||||||
164 | if ( $counter == $this->page ) { |
|||||||||||
165 | $this->pagination .= "<span class=\"selected-page\">$counter</span>"; |
|||||||||||
166 | } else { |
|||||||||||
167 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( $counter ) . "\">$counter</a>"; |
|||||||||||
168 | } |
|||||||||||
169 | } |
|||||||||||
170 | $this->pagination .= "..."; |
|||||||||||
171 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( $lpm1 ) . "\">$lpm1</a>"; |
|||||||||||
172 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( $this->page_count ) . "\">$this->page_count</a>"; |
|||||||||||
173 | } //in middle; hide some front and some back |
|||||||||||
174 | elseif ( $this->page_count - ( $this->adjacents * 2 ) > $this->page && $this->page > ( $this->adjacents * 2 ) ) { |
|||||||||||
175 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( 1 ) . "\">1</a>"; |
|||||||||||
176 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( 2 ) . "\">2</a>"; |
|||||||||||
177 | $this->pagination .= "..."; |
|||||||||||
178 | for ( $counter = $this->page - $this->adjacents; $counter <= $this->page + $this->adjacents; $counter ++ ) { |
|||||||||||
179 | if ( $counter == $this->page ) { |
|||||||||||
180 | $this->pagination .= "<span class=\"selected-page\">$counter</span>"; |
|||||||||||
181 | } else { |
|||||||||||
182 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( $counter ) . "\">$counter</a>"; |
|||||||||||
183 | } |
|||||||||||
184 | } |
|||||||||||
185 | $this->pagination .= "..."; |
|||||||||||
186 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( $lpm1 ) . "\">$lpm1</a>"; |
|||||||||||
187 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( $this->page_count ) . "\">$this->page_count</a>"; |
|||||||||||
188 | } //close to end; only hide early pages |
|||||||||||
189 | else { |
|||||||||||
190 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( 1 ) . "\">1</a>"; |
|||||||||||
191 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( 2 ) . "\">2</a>"; |
|||||||||||
192 | $this->pagination .= "..."; |
|||||||||||
193 | for ( $counter = $this->page_count - ( 2 + ( $this->adjacents * 2 ) ); $counter <= $this->page_count; $counter ++ ) { |
|||||||||||
194 | if ( $counter == $this->page ) { |
|||||||||||
195 | $this->pagination .= "<span class=\"selected-page\">$counter</span>"; |
|||||||||||
196 | } else { |
|||||||||||
197 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( $counter ) . "\">$counter</a>"; |
|||||||||||
198 | } |
|||||||||||
199 | } |
|||||||||||
200 | } |
|||||||||||
201 | } |
|||||||||||
202 | if ( $this->page ) { |
|||||||||||
203 | //siguiente button |
|||||||||||
204 | if ( $this->page < $counter - 1 ) { |
|||||||||||
205 | $this->pagination .= "<a href=\"" . $this->get_page_number_url( $next ) . "\" class=\"next\">$n</a>"; |
|||||||||||
206 | } else { |
|||||||||||
207 | $this->pagination .= "<span class=\"disabled\">$n</span>"; |
|||||||||||
208 | } |
|||||||||||
209 | } |
|||||||||||
210 | } |
|||||||||||
211 | } |
|||||||||||
212 | } |
|||||||||||
213 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.