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 | You may not change or alter any portion of this comment or credits |
||
4 | of supporting developers from this source code or any supporting source code |
||
5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | |||
7 | This program is distributed in the hope that it will be useful, |
||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | /** |
||
12 | * Alumni module for Xoops |
||
13 | * |
||
14 | * @copyright XOOPS Project https://xoops.org/ |
||
15 | * @license GPL 2.0 or later |
||
16 | * @package alumni |
||
17 | * @since 2.6.x |
||
18 | * @author John Mordo (jlm69) |
||
19 | */ |
||
20 | |||
21 | use Xoops\Core\Database\Connection; |
||
22 | use Xoops\Core\Kernel\XoopsObject; |
||
23 | use Xoops\Core\Kernel\XoopsPersistableObjectHandler; |
||
24 | |||
25 | //defined('XOOPS_ROOT_PATH') or exit('XOOPS root path not defined'); |
||
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. ![]() |
|||
26 | $xoops = Xoops::getInstance(); |
||
27 | |||
28 | /** |
||
29 | * Class AlumniListing |
||
30 | */ |
||
31 | class AlumniListing extends XoopsObject |
||
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. ![]() |
|||
32 | { |
||
33 | /** |
||
34 | * @var Alumni |
||
35 | * @access public |
||
36 | */ |
||
37 | public $alumni = null; |
||
38 | |||
39 | /** |
||
40 | * Constructor |
||
41 | */ |
||
42 | public function __construct() |
||
43 | { |
||
44 | global $xoops; |
||
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
}
}
![]() |
|||
45 | $this->db = $xoops->db(); |
||
46 | $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 11); |
||
47 | $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 11); |
||
48 | $this->initVar('name', XOBJ_DTYPE_TXTBOX, null, false); |
||
49 | $this->initVar('mname', XOBJ_DTYPE_TXTBOX, null, false); |
||
50 | $this->initVar('lname', XOBJ_DTYPE_TXTBOX, null, false); |
||
51 | $this->initVar('school', XOBJ_DTYPE_TXTBOX, null, false); |
||
52 | $this->initVar('year', XOBJ_DTYPE_TXTBOX, null, false); |
||
53 | $this->initVar('studies', XOBJ_DTYPE_TXTBOX, null, false); |
||
54 | $this->initVar('activities', XOBJ_DTYPE_TXTAREA, null, false); |
||
55 | $this->initVar('extrainfo', XOBJ_DTYPE_TXTAREA, null, false); |
||
56 | $this->initVar('occ', XOBJ_DTYPE_TXTBOX, null, false); |
||
57 | $this->initVar('date', XOBJ_DTYPE_INT, null, false, 10); |
||
58 | $this->initVar('email', XOBJ_DTYPE_TXTBOX, null, false); |
||
59 | $this->initVar('submitter', XOBJ_DTYPE_TXTBOX, null, false); |
||
60 | $this->initVar('usid', XOBJ_DTYPE_TXTBOX, null, false); |
||
61 | $this->initVar('town', XOBJ_DTYPE_TXTBOX, null, false); |
||
62 | $this->initVar('valid', XOBJ_DTYPE_INT, null, false, 3); |
||
63 | $this->initVar('photo', XOBJ_DTYPE_TXTBOX, null, false); |
||
64 | $this->initVar('photo2', XOBJ_DTYPE_TXTBOX, null, false); |
||
65 | $this->initVar('view', XOBJ_DTYPE_TXTBOX, null, false); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @return mixed |
||
70 | */ |
||
71 | public function get_new_id() |
||
0 ignored issues
–
show
function get_new_id() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
72 | { |
||
73 | $xoops = Xoops::getInstance(); |
||
74 | $new_id = $xoops->db()->getInsertId(); |
||
0 ignored issues
–
show
$new_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
75 | |||
76 | return $new_id; |
||
0 ignored issues
–
show
$new_id does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$ ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
77 | } |
||
78 | |||
79 | |||
80 | /** |
||
81 | * @return mixed |
||
82 | */ |
||
83 | public function updateCounter() |
||
84 | { |
||
85 | // return $this->updateCounter($this->getVar('lid')); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
74% 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. ![]() |
|||
86 | |||
87 | return $this->alumni->getHandler('listing')->updateCounter($this->getVar('lid')); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Class AlumniListingHandler |
||
93 | */ |
||
94 | class AlumniListingHandler extends XoopsPersistableObjectHandler |
||
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. ![]() |
|||
95 | { |
||
96 | /** |
||
97 | * @param null|Connection|XoopsDatabase $db |
||
0 ignored issues
–
show
|
|||
98 | */ |
||
99 | public function __construct(Connection $db = null) |
||
0 ignored issues
–
show
|
|||
100 | { |
||
101 | parent::__construct($db, 'alumni_listing', 'alumnilisting', 'lid', 'title'); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * @param int $start |
||
106 | * @param int $limit |
||
107 | * @param string $sort |
||
108 | * @param string $order |
||
109 | * @return array |
||
110 | */ |
||
111 | public function getListingPublished($start = 0, $limit = 0, $sort = 'date', $order = 'ASC') |
||
112 | { |
||
113 | $helper = Alumni::getInstance(); |
||
114 | $xoops = $helper->xoops(); |
||
115 | $moduleId = $helper->getModule()->getVar('mid'); |
||
116 | // get permitted id |
||
117 | $groups = $xoops->isUser() ? $xoops->user->getGroups() : '3'; |
||
118 | $alumniIds = $helper->getGrouppermHandler()->getItemIds('alumni_view', $groups, $moduleId); |
||
119 | // criteria |
||
120 | $criteria = new CriteriaCompo(); |
||
121 | $criteria->add(new Criteria('valid', 1, '=')); |
||
122 | $criteria->add(new Criteria('cid', '(' . implode(', ', $alumniIds) . ')', 'IN')); |
||
123 | $criteria->setSort($sort); |
||
124 | $criteria->setOrder($order); |
||
125 | $criteria->setStart($start); |
||
126 | $criteria->setLimit($limit); |
||
127 | |||
128 | return parent::getAll($criteria); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
getAll() instead of getListingPublished() ). Are you sure this is correct? If so, you might want to change this to $this->getAll() .
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @param null $keys |
||
133 | * @param null $format |
||
134 | * @param null $maxDepth |
||
135 | * @return mixed |
||
136 | */ |
||
137 | public function getValues($keys = null, $format = null, $maxDepth = null) |
||
138 | { |
||
139 | $page = Page::getInstance(); |
||
0 ignored issues
–
show
$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 ![]() |
|||
140 | $ret = parent::getValues($keys, $format, $maxDepth); |
||
141 | $ret['rating'] = number_format($this->getVar('rating'), 1); |
||
142 | $ret['lid'] = $this->getVar('lid'); |
||
143 | $ret['name'] = $this->getVar('name'); |
||
144 | $ret['mname'] = $this->getVar('mname'); |
||
145 | $ret['lname'] = $this->getVar('lname'); |
||
146 | $ret['school'] = $this->getVar('school'); |
||
147 | $ret['year'] = $this->getVar('year'); |
||
148 | $ret['submitter'] = $this->getVar('submitter'); |
||
149 | $ret['date'] = $this->getVar('date'); |
||
150 | |||
151 | return $ret; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * @param int $start |
||
156 | * @param int $limit |
||
157 | * @param string $sort |
||
158 | * @param string $order |
||
159 | * @return int |
||
160 | */ |
||
161 | public function countAlumni($start = 0, $limit = 0, $sort = 'date', $order = 'ASC') |
||
162 | { |
||
163 | $criteria = new CriteriaCompo(); |
||
164 | $criteria->setSort($sort); |
||
165 | $criteria->setOrder($order); |
||
166 | $criteria->setStart($start); |
||
167 | $criteria->setLimit($limit); |
||
168 | |||
169 | return parent::getCount($criteria); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
getCount() instead of countAlumni() ). Are you sure this is correct? If so, you might want to change this to $this->getCount() .
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
170 | } |
||
171 | |||
172 | /** |
||
173 | * @param $lid |
||
174 | * @return bool |
||
175 | */ |
||
176 | public function updateCounter($lid) |
||
0 ignored issues
–
show
function updateCounter() does not seem to conform to the naming convention (^(?:is|has|should|may|supports) ).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. ![]() |
|||
177 | { |
||
178 | $xoops = Xoops::getInstance(); |
||
0 ignored issues
–
show
$xoops 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 ![]() |
|||
179 | $listingObj = $this->get($lid); |
||
180 | if (!is_object($listingObj)) { |
||
181 | return false; |
||
182 | } |
||
183 | $listingObj->setVar('view', $listingObj->getVar('view', 'n') + 1); |
||
184 | $this->insert($listingObj, true); |
||
185 | |||
186 | return true; |
||
187 | } |
||
188 | } |
||
189 |
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.