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 | * |
||
4 | * Module: SmartCourse |
||
5 | * Author: The SmartFactory <www.smartfactory.ca> |
||
6 | * Licence: GNU |
||
7 | * @param bool $showmenu |
||
8 | * @param int $offerid |
||
9 | * @param string $fct |
||
10 | */ |
||
11 | |||
12 | function editoffer($showmenu = false, $offerid = 0, $fct = '') |
||
13 | { |
||
14 | global $smartPartnerOfferHandler, $smartPartnerCategoryHandler, $smartPartnerPartnerHandler; |
||
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
}
}
![]() |
|||
15 | |||
16 | $offerObj = $smartPartnerOfferHandler->get($offerid); |
||
17 | |||
18 | if ($offerObj->isNew()) { |
||
19 | $breadcrumb = _AM_SPARTNER_OFFERS . ' > ' . _AM_SPARTNER_CREATINGNEW; |
||
0 ignored issues
–
show
$breadcrumb 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 ![]() |
|||
20 | $title = _AM_SPARTNER_OFFER_CREATE; |
||
21 | $info = _AM_SPARTNER_OFFER_CREATE_INFO; |
||
22 | $collaps_name = 'offercreate'; |
||
23 | $form_name = _AM_SPARTNER_OFFER_CREATE; |
||
24 | $submit_button_caption = null; |
||
25 | $offerObj->setVar('date_sub', time()); |
||
26 | } else { |
||
27 | $breadcrumb = _AM_SPARTNER_OFFERS . ' > ' . _AM_SPARTNER_EDITING; |
||
0 ignored issues
–
show
$breadcrumb 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 ![]() |
|||
28 | $title = _AM_SPARTNER_OFFER_EDIT; |
||
29 | $info = _AM_SPARTNER_OFFER_EDIT_INFO; |
||
30 | $collaps_name = 'offeredit'; |
||
31 | $form_name = _AM_SPARTNER_OFFER_EDIT; |
||
32 | $submit_button_caption = null; |
||
33 | } |
||
34 | $partnerObj = $smartPartnerPartnerHandler->get($offerObj->getVar('partnerid', 'e')); |
||
0 ignored issues
–
show
$partnerObj 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 ![]() |
|||
35 | $offerObj->hideFieldFromForm('date_sub'); |
||
36 | $menuTab = 3; |
||
0 ignored issues
–
show
$menuTab 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 ![]() |
|||
37 | |||
38 | if ($showmenu) { |
||
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. ![]() |
|||
39 | //smart_adminMenu($menuTab, $breadcrumb); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
75% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
40 | } |
||
41 | echo "<br>\n"; |
||
42 | smart_collapsableBar($collaps_name, $title, $info); |
||
43 | |||
44 | $sform = $offerObj->getForm($form_name, 'addoffer', false, $submit_button_caption); |
||
45 | if ($fct === 'app') { |
||
46 | $sform->addElement(new XoopsFormHidden('fct', 'app')); |
||
47 | } |
||
48 | $sform->display(); |
||
49 | smart_close_collapsable($collaps_name); |
||
50 | } |
||
51 | |||
52 | include_once __DIR__ . '/admin_header.php'; |
||
53 | |||
54 | $op = ''; |
||
55 | if (isset($_GET['op'])) { |
||
56 | $op = $_GET['op']; |
||
57 | } |
||
58 | if (isset($_POST['op'])) { |
||
59 | $op = $_POST['op']; |
||
60 | } |
||
61 | |||
62 | switch ($op) { |
||
63 | case 'mod': |
||
64 | $offerid = isset($_GET['offerid']) ? (int)$_GET['offerid'] : 0; |
||
65 | $fct = isset($_GET['fct']) ? $_GET['fct'] : ''; |
||
66 | smart_xoops_cp_header(); |
||
67 | |||
68 | editoffer(true, $offerid, $fct); |
||
69 | break; |
||
70 | |||
71 | case 'addoffer': |
||
72 | include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
||
73 | |||
74 | $controller = new SmartObjectController($smartPartnerOfferHandler); |
||
75 | $offerObj = $controller->storeSmartObject(); |
||
76 | $fct = isset($_POST['fct']) ? $_POST['fct'] : ''; |
||
77 | |||
78 | if ($offerObj->hasError()) { |
||
79 | redirect_header($smart_previous_page, 3, _CO_SOBJECT_SAVE_ERROR . $offerObj->getHtmlErrors()); |
||
80 | } else { |
||
81 | $partnerObj = $smartPartnerPartnerHandler->get($offerObj->getVar('partnerid', 'e')); |
||
82 | $partnerObj->setUpdated(); |
||
83 | if ($_POST['offerid'] == '') { |
||
84 | $offerObj->sendNotifications(array(_SPARTNER_NOT_OFFER_NEW)); |
||
85 | } |
||
86 | |||
87 | redirect_header(smart_get_page_before_form(), 3, _CO_SOBJECT_SAVE_SUCCESS); |
||
88 | } |
||
89 | exit; |
||
90 | break; |
||
91 | |||
92 | case 'del': |
||
93 | include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php'; |
||
94 | $controller = new SmartObjectController($smartPartnerOfferHandler); |
||
95 | $controller->handleObjectDeletion(); |
||
96 | break; |
||
97 | |||
98 | case 'default': |
||
99 | default: |
||
100 | include_once(XOOPS_ROOT_PATH . '/modules/smartobject/include/functions.php'); |
||
101 | smart_xoops_cp_header(); |
||
102 | |||
103 | //add navigation icon |
||
104 | $indexAdmin = new ModuleAdmin(); |
||
105 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
||
106 | |||
107 | //add button for creating a new offer |
||
108 | $indexAdmin->addItemButton(_AM_SPARTNER_OFFER_CREATE, 'offer.php?op=mod', 'add', ''); |
||
109 | echo $indexAdmin->renderButton('left', ''); |
||
110 | |||
111 | //smart_adminMenu(3, _AM_SPARTNER_OFFERS); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
63% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
112 | |||
113 | // echo "<br>\n"; |
||
114 | // echo "<form><div style=\"margin-bottom: 12px;\">"; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
43% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
115 | // echo "<input type='button' name='button' onclick=\"location='offer.php?op=mod'\" value='" . _AM_SPARTNER_OFFER_CREATE . "'> "; |
||
116 | // echo "</div></form>"; |
||
117 | |||
118 | smart_collapsableBar('createdoffers', _AM_SPARTNER_OFFERS, _AM_SPARTNER_OFFERS_DSC); |
||
119 | |||
120 | include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjecttable.php'; |
||
121 | $objectTable = new SmartObjectTable($smartPartnerOfferHandler); |
||
122 | $objectTable->addFilter('partnerid', 'getPartnerList'); |
||
123 | $objectTable->addFilter('status', 'getStatusList'); |
||
124 | $objectTable->addColumn(new SmartObjectColumn('title', 'left')); |
||
125 | $objectTable->addColumn(new SmartObjectColumn('partnerid', 'center', 100)); |
||
126 | $objectTable->addColumn(new SmartObjectColumn('status', 'center', 100)); |
||
127 | $objectTable->render(); |
||
128 | |||
129 | echo '<br>'; |
||
130 | smart_close_collapsable('createdoffers'); |
||
131 | echo '<br>'; |
||
132 | |||
133 | break; |
||
134 | } |
||
135 | |||
136 | //smart_modFooter(); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
67% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
137 | //xoops_cp_footer(); |
||
138 | include_once __DIR__ . '/admin_footer.php'; |
||
139 |
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.