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 |
||
0 ignored issues
–
show
|
|||
2 | // $Id: navegacao.php,v 1.6 2007/03/24 17:50:52 marcellobrandao Exp $ |
||
3 | // ------------------------------------------------------------------------ // |
||
4 | // XOOPS - PHP Content Management System // |
||
5 | // Copyright (c) 2000 XOOPS.org // |
||
6 | // <http://www.xoops.org/> // |
||
7 | // ------------------------------------------------------------------------ // |
||
8 | // This program is free software; you can redistribute it and/or modify // |
||
9 | // it under the terms of the GNU General Public License as published by // |
||
10 | // the Free Software Foundation; either version 2 of the License, or // |
||
11 | // (at your option) any later version. // |
||
12 | // // |
||
13 | // You may not change or alter any portion of this comment or credits // |
||
14 | // of supporting developers from this source code or any supporting // |
||
15 | // source code which is considered copyrighted (c) material of the // |
||
16 | // original comment or credit authors. // |
||
17 | // // |
||
18 | // This program is distributed in the hope that it will be useful, // |
||
19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
21 | // GNU General Public License for more details. // |
||
22 | // // |
||
23 | // You should have received a copy of the GNU General Public License // |
||
24 | // along with this program; if not, write to the Free Software // |
||
25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
26 | // ------------------------------------------------------------------------ // |
||
27 | include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
28 | |||
29 | /** |
||
30 | * Class NavegadorProva |
||
31 | */ |
||
32 | class NavegadorProva extends XoopsPageNav |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
33 | { |
||
34 | /** |
||
35 | * Create navigation with images |
||
36 | * |
||
37 | * @param int $cod_perguntas |
||
0 ignored issues
–
show
Should the type for parameter
$cod_perguntas not be integer|null ?
This check looks for It makes a suggestion as to what type it considers more descriptive. Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
38 | * @param $cod_perguntas_respondidas |
||
39 | * @param integer $offset |
||
40 | * |
||
41 | * @return string |
||
0 ignored issues
–
show
|
|||
42 | */ |
||
43 | public function renderImageNav($cod_perguntas = null, $cod_perguntas_respondidas = null, $offset = 1) |
||
44 | { |
||
45 | global $xoopsModule; |
||
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
46 | $vazio = array(); |
||
47 | $largura = 50 * $offset; |
||
48 | $perguntas = @array_merge($perguntas, $vazio); |
||
0 ignored issues
–
show
The variable
$perguntas seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?
This error can happen if you refactor code and forget to move the variable initialization. Let’s take a look at a simple example: function someFunction() {
$x = 5;
echo $x;
}
The above code is perfectly fine. Now imagine that we re-order the statements: function someFunction() {
echo $x;
$x = 5;
}
In that case, ![]() $perguntas is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
49 | if ($this->total < $this->perpage) { |
||
50 | return null; |
||
51 | } |
||
52 | $total_pages = ceil($this->total / $this->perpage); |
||
53 | |||
54 | if ($total_pages > 1) { |
||
55 | $ret = '<table align="center" style="width:' . $largura . 'px;"><tr>'; |
||
56 | |||
57 | $prev = $this->current - $this->perpage; |
||
58 | if ($prev >= 0) { |
||
59 | $ret .= '<td align="right"><a href="' . $this->url . $prev . $this->extra . '"> |
||
60 | <img src="assets/images/anterior.gif" border="0" alt="' . _MA_ASSESSMENT_ANTERIOR . '" title="' . _MA_ASSESSMENT_ANTERIOR . '"></a></td> '; |
||
61 | } |
||
62 | $ret .= '<td align="center"><table><tr>'; |
||
63 | $next = $this->current + $this->perpage; |
||
64 | |||
65 | $counter = 1; |
||
66 | $current_page = (int)floor(($this->current + $this->perpage) / $this->perpage); |
||
0 ignored issues
–
show
$current_page is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
67 | while ($counter <= $total_pages) { |
||
68 | $cod_pergunta_atual = $cod_perguntas[$counter - 1]; |
||
69 | |||
70 | if (in_array($cod_pergunta_atual, $cod_perguntas_respondidas)) { |
||
71 | $ret .= '<td valign="center" style="height=20px; text-align:center; background:url(assets/images/feita.jpg); background-repeat:no-repeat;background-position:center;"> |
||
72 | <a rel="sad" href="' |
||
73 | . $this->url |
||
74 | . (($counter - 1) * $this->perpage) |
||
75 | . $this->extra |
||
76 | . '">' |
||
77 | . $counter |
||
78 | . '</a></td>'; |
||
79 | } else { |
||
80 | $ret .= '<td valign="center" style="height=20px; text-align:center; background:url(assets/images/naofeita.jpg); background-repeat:no-repeat;background-position:center;"> |
||
81 | <a href="' |
||
82 | . $this->url |
||
83 | . (($counter - 1) * $this->perpage) |
||
84 | . $this->extra |
||
85 | . '">' |
||
86 | . $counter |
||
87 | . '</a></td>'; |
||
88 | } |
||
89 | |||
90 | if ((($counter % $offset) == 0) & $counter != $total_pages - 1) { |
||
91 | $ret .= '</tr><tr>'; |
||
92 | } |
||
93 | ++$counter; |
||
94 | } |
||
95 | $ret .= '</tr></table></td>'; |
||
96 | if ($this->total > $next) { |
||
97 | $ret .= '<td valign="middle"><a href="' . $this->url . $next . $this->extra . '"><img src="assets/images/proximo.gif" border="0" alt="' . _MA_ASSESSMENT_PROXIMO . '" title="' . _MA_ASSESSMENT_PROXIMO . '"></a></td>'; |
||
98 | } |
||
99 | |||
100 | $ret .= '</tr></table>'; |
||
101 | } |
||
102 | |||
103 | return $ret; |
||
0 ignored issues
–
show
The variable
$ret does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
104 | } |
||
105 | } |
||
106 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.