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 | ||||||||||||
3 | use Bitrix\Main\Loader; |
|||||||||||
4 | use DigitalWand\AdminHelper\Helper\AdminBaseHelper; |
|||||||||||
5 | use DigitalWand\AdminHelper\Helper\AdminListHelper; |
|||||||||||
6 | use DigitalWand\AdminHelper\Helper\AdminEditHelper; |
|||||||||||
7 | use DigitalWand\AdminHelper\Helper\AdminInterface; |
|||||||||||
8 | ||||||||||||
9 | require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_admin_before.php'); |
|||||||||||
10 | ||||||||||||
11 | Loader::includeModule('digitalwand.admin_helper'); |
|||||||||||
12 | ||||||||||||
13 | function getRequestParams($param) |
|||||||||||
0 ignored issues
–
show
getRequestParams uses the super-global variable $_REQUEST which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
![]() |
||||||||||||
14 | { |
|||||||||||
15 | if (!isset($_REQUEST[$param])) { |
|||||||||||
16 | return false; |
|||||||||||
17 | } |
|||||||||||
18 | else { |
|||||||||||
19 | return htmlspecialcharsbx($_REQUEST[$param]); |
|||||||||||
20 | } |
|||||||||||
21 | } |
|||||||||||
22 | ||||||||||||
23 | /** |
|||||||||||
24 | * Очищаем переменные сессии, чтобы сортировка восстанавливалась с учетом $table_id. |
|||||||||||
25 | * |
|||||||||||
26 | * @global CMain $APPLICATION |
|||||||||||
27 | */ |
|||||||||||
28 | global $APPLICATION; |
|||||||||||
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
}
}
![]() |
||||||||||||
29 | $uniq = md5($APPLICATION->GetCurPage()); |
|||||||||||
30 | ||||||||||||
31 | if (isset($_SESSION["SESS_SORT_BY"][$uniq])) { |
|||||||||||
32 | unset($_SESSION["SESS_SORT_BY"][$uniq]); |
|||||||||||
33 | } |
|||||||||||
34 | if (isset($_SESSION["SESS_SORT_ORDER"][$uniq])) { |
|||||||||||
35 | unset($_SESSION["SESS_SORT_ORDER"][$uniq]); |
|||||||||||
36 | } |
|||||||||||
37 | ||||||||||||
38 | $module = getRequestParams('module'); |
|||||||||||
39 | $view = getRequestParams('view'); |
|||||||||||
40 | $entity = getRequestParams('entity'); |
|||||||||||
41 | ||||||||||||
42 | if (!$module OR !$view OR !Loader::IncludeModule($module)) { |
|||||||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Using logical operators such as
or 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. ![]() |
||||||||||||
43 | include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; |
|||||||||||
44 | } |
|||||||||||
45 | ||||||||||||
46 | // Собираем имя класса админского интерфейса |
|||||||||||
47 | $moduleNameParts = explode('.', $module); |
|||||||||||
48 | $entityNameParts = explode('_', $entity); |
|||||||||||
49 | $interfaceNameParts = array_merge($moduleNameParts, $entityNameParts); |
|||||||||||
50 | $interfaceNameClass = null; |
|||||||||||
51 | $viewParts = explode('_', $view); |
|||||||||||
52 | ||||||||||||
53 | $count = count($viewParts); |
|||||||||||
54 | for ($i = 0; $i < $count; $i++) { |
|||||||||||
55 | $interfaceName = implode('', array_map('ucfirst', $viewParts)); |
|||||||||||
56 | $parts = $interfaceNameParts; |
|||||||||||
57 | $parts[] = $interfaceName . 'AdminInterface'; |
|||||||||||
58 | $class = array_map('ucfirst', $parts); |
|||||||||||
59 | $interfaceNameClass = implode('\\', $class); |
|||||||||||
60 | ||||||||||||
61 | if (class_exists($interfaceNameClass)) { |
|||||||||||
62 | break; |
|||||||||||
63 | } |
|||||||||||
64 | else { |
|||||||||||
65 | $className = array_pop($parts); |
|||||||||||
66 | $parts[] = 'AdminInterface'; |
|||||||||||
67 | $parts[] = $className; |
|||||||||||
68 | $class = array_map('ucfirst', $parts); |
|||||||||||
69 | $interfaceNameClass = implode('\\', $class); |
|||||||||||
70 | if (class_exists($interfaceNameClass)) { |
|||||||||||
71 | break; |
|||||||||||
72 | } |
|||||||||||
73 | } |
|||||||||||
74 | array_pop($viewParts); |
|||||||||||
75 | } |
|||||||||||
76 | ||||||||||||
77 | /** |
|||||||||||
78 | * @var AdminInterface $interfaceNameClass |
|||||||||||
79 | */ |
|||||||||||
80 | ||||||||||||
81 | if ($interfaceNameClass && class_exists($interfaceNameClass)) { |
|||||||||||
82 | $interfaceNameClass::register(); |
|||||||||||
83 | } |
|||||||||||
84 | ||||||||||||
85 | list($helper, $interface) = AdminBaseHelper::getGlobalInterfaceSettings($module, $view); |
|||||||||||
0 ignored issues
–
show
|
||||||||||||
86 | ||||||||||||
87 | if (!$helper OR !$interface) { |
|||||||||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Using logical operators such as
or 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. ![]() |
||||||||||||
88 | include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; |
|||||||||||
89 | } |
|||||||||||
90 | ||||||||||||
91 | $isPopup = isset($_REQUEST['popup']) AND $_REQUEST['popup'] == 'Y'; |
|||||||||||
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. ![]() |
||||||||||||
92 | $fields = isset($interface['FIELDS']) ? $interface['FIELDS'] : array(); |
|||||||||||
93 | $tabs = isset($interface['TABS']) ? $interface['TABS'] : array(); |
|||||||||||
94 | $helperType = false; |
|||||||||||
95 | ||||||||||||
96 | if (is_subclass_of($helper, 'DigitalWand\AdminHelper\Helper\AdminEditHelper')) { |
|||||||||||
97 | $helperType = 'edit'; |
|||||||||||
98 | /** |
|||||||||||
99 | * @var AdminEditHelper $adminHelper |
|||||||||||
100 | */ |
|||||||||||
101 | $adminHelper = new $helper($fields, $tabs); |
|||||||||||
102 | } |
|||||||||||
103 | elseif (is_subclass_of($helper, 'DigitalWand\AdminHelper\Helper\AdminListHelper')) { |
|||||||||||
104 | $helperType = 'list'; |
|||||||||||
105 | /** |
|||||||||||
106 | * @var AdminListHelper $adminHelper |
|||||||||||
107 | */ |
|||||||||||
108 | $adminHelper = new $helper($fields, $isPopup); |
|||||||||||
109 | $adminHelper->buildList(array($by => $order)); |
|||||||||||
110 | } |
|||||||||||
111 | elseif (is_subclass_of($helper, 'DigitalWand\AdminHelper\Helper\AdminBaseHelper')) { |
|||||||||||
112 | $adminHelper = new $helper($fields, $tabs); |
|||||||||||
113 | } |
|||||||||||
114 | else { |
|||||||||||
115 | include $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/admin/404.php'; |
|||||||||||
116 | exit(); |
|||||||||||
117 | } |
|||||||||||
118 | ||||||||||||
119 | if ($isPopup) { |
|||||||||||
120 | require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_popup_admin.php"); |
|||||||||||
121 | } |
|||||||||||
122 | else { |
|||||||||||
123 | require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"); |
|||||||||||
124 | } |
|||||||||||
125 | ||||||||||||
126 | if ($helperType == 'list') { |
|||||||||||
127 | $adminHelper->createFilterForm(); |
|||||||||||
128 | } |
|||||||||||
129 | ||||||||||||
130 | $adminHelper->show(); |
|||||||||||
131 | ||||||||||||
132 | if ($isPopup) { |
|||||||||||
133 | require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_popup_admin.php"); |
|||||||||||
134 | } |
|||||||||||
135 | else { |
|||||||||||
136 | require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php"); |
|||||||||||
137 | } |
|||||||||||
138 |
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.