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 | 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 | /** |
||
13 | * Alumni module for Xoops |
||
14 | * |
||
15 | * @copyright XOOPS Project https://xoops.org/ |
||
16 | * @license GPL 2.0 or later |
||
17 | * @package alumni |
||
18 | * @since 2.6.x |
||
19 | * @author John Mordo (jlm69) |
||
20 | */ |
||
21 | |||
22 | use Xoops\Module\Plugin\PluginAbstract; |
||
23 | use Xmf\Metagen; |
||
24 | use Xoops\Core\Request; |
||
25 | |||
26 | /** |
||
27 | * Class AlumniSearchPlugin |
||
28 | */ |
||
29 | class AlumniSearchPlugin extends PluginAbstract implements SearchPluginInterface |
||
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. ![]() |
|||
30 | { |
||
31 | |||
32 | /** |
||
33 | * @param $queryArray |
||
34 | * @param $andor |
||
35 | * @param $limit |
||
36 | * @param $offset |
||
37 | * @param $userid |
||
38 | * @return array |
||
39 | */ |
||
40 | public function search($queryArray, $andor, $limit, $offset, $userid) |
||
41 | { |
||
42 | $xoops = Xoops::getInstance(); |
||
43 | $helper = Xoops::getModuleHelper('alumni'); |
||
44 | $module_id = $helper->getModule()->getVar('mid'); |
||
0 ignored issues
–
show
$module_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. ![]() |
|||
45 | $listing_Handler = $helper->getHandler('listing'); |
||
0 ignored issues
–
show
$listing_Handler 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. ![]() $listing_Handler 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 ![]() |
|||
46 | $groups = $xoops->getUserGroups(); |
||
47 | $alumni_ids = $xoops->getHandlerGroupPermission()->getItemIds('alumni_view', $groups, $module_id); |
||
0 ignored issues
–
show
$alumni_ids 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. ![]() |
|||
48 | $all_ids = implode(', ', $alumni_ids); |
||
0 ignored issues
–
show
$all_ids 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. ![]() |
|||
49 | |||
50 | $by_cat = Request::getInt('by_cat', 0); |
||
0 ignored issues
–
show
$by_cat 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. ![]() |
|||
51 | $andor = 'and' == strtolower($andor) ? 'and' : 'or'; |
||
52 | |||
53 | $qb = \Xoops::getInstance()->db()->createXoopsQueryBuilder(); |
||
0 ignored issues
–
show
|
|||
54 | $eb = $qb->expr(); |
||
0 ignored issues
–
show
|
|||
55 | $qb->select('DISTINCT *')->fromPrefix('alumni_listing')->where($eb->eq('valid', '1'))->orderBy('lname', 'DESC')->setFirstResult($offset)->setMaxResults($limit); |
||
56 | if (is_array($queryArray) && !empty($queryArray)) { |
||
57 | $queryParts = []; |
||
58 | foreach ($queryArray as $i => $q) { |
||
59 | $query = ':query' . $i; |
||
60 | $qb->setParameter($query, '%' . $q . '%', \PDO::PARAM_STR); |
||
61 | $queryParts[] = $eb->orX($eb->like('name', $query), $eb->like('mname', $query), $eb->like('lname', $query), $eb->like('school', $query), $eb->like('year', $query)); |
||
62 | } |
||
63 | |||
64 | $qb->andWhere($eb->in('cid', [$all_ids])); |
||
0 ignored issues
–
show
$all_ids 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. ![]() |
|||
65 | if ($by_cat) { |
||
0 ignored issues
–
show
$by_cat 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. ![]() |
|||
66 | $qb->andWhere($eb->eq('cid', $by_cat)); |
||
0 ignored issues
–
show
$by_cat 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. ![]() |
|||
67 | } |
||
68 | if ('and' == $andor) { |
||
69 | $qb->andWhere(call_user_func_array([$eb, 'andX'], $queryParts)); |
||
70 | } else { |
||
71 | $qb->andWhere(call_user_func_array([$eb, 'orX'], $queryParts)); |
||
72 | } |
||
73 | } else { |
||
74 | $qb->setParameter(':uid', (int)$userid, \PDO::PARAM_INT); |
||
75 | $qb->andWhere($eb->eq('usid', ':uid')); |
||
76 | } |
||
77 | |||
78 | $myts = MyTextSanitizer::getInstance(); |
||
0 ignored issues
–
show
$myts 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 ![]() |
|||
79 | $items = []; |
||
80 | $result = $qb->execute(); |
||
81 | while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) { |
||
82 | $items[] = [ |
||
83 | 'title' => $myrow['name'] . ' ' . $myrow['mname'] . ' ' . $myrow['lname'] . ' --- ' . $myrow['school'] . ' --- ' . $myrow['year'], |
||
84 | 'link' => 'listing.php?lid=' . $myrow['lid'], |
||
85 | 'time' => $myrow['date'], |
||
86 | 'uid' => $myrow['usid'], |
||
87 | 'image' => 'images/cat/default.gif', |
||
88 | ]; |
||
89 | } |
||
90 | return $items; |
||
91 | } |
||
92 | } |
||
93 |
This check looks for classes that have been defined more than once.
If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.
This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.