Issues (884)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

class/plugin/notifications.php (18 issues)

Upgrade to new PHP Analysis Engine

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
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 27 and the first side effect is on line 21.

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.

Loading history...
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
defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
22
$moduleDirName = basename(dirname(dirname(__DIR__)));
23
24
/**
25
 * Class AlumniNotificationsPlugin
26
 */
27
class AlumniNotificationsPlugin extends Xoops\Module\Plugin\PluginAbstract implements NotificationsPluginInterface
0 ignored issues
show
Coding Style Compatibility introduced by
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.

Loading history...
28
{
29
    /**
30
     * @param string $category
31
     * @param int    $item_id
32
     *
33
     * @return array
34
     */
35
    public function item($category, $item_id)
0 ignored issues
show
$item_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.

Loading history...
36
    {
37
        $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 $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
38
        $item    = [];
39
        $item_id = (int)$item_id;
0 ignored issues
show
$item_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.

Loading history...
40
41
        if ('global' === $category) {
42
            $item['name'] = '';
43
            $item['url']  = '';
44
45
            return $item;
46
        }
47
48
        global $xoopsDB;
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 global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
49
50 View Code Duplication
        if ('category' === $category) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
52
            // Assume we have a valid topid id
53
            $sql          = 'SELECT title  FROM ' . $xoopsDB->prefix('alumni_categories') . ' WHERE cid = ' . $item_id . ' LIMIT 1';
0 ignored issues
show
$item_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.

Loading history...
54
            $result       = $xoopsDB->query($sql); // TODO: error check
55
            $result_array = $xoopsDB->fetchArray($result);
0 ignored issues
show
$result_array 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.

Loading history...
56
            $item['name'] = $result_array['title'];
0 ignored issues
show
$result_array 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.

Loading history...
57
            $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/categories.php?cid=' . $item_id;
0 ignored issues
show
$item_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.

Loading history...
The variable $module does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
58
59
            return $item;
60
        }
61
62 View Code Duplication
        if ('listing' === $category) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
            // Assume we have a valid post id
64
            $sql          = 'SELECT title FROM ' . $xoopsDB->prefix('alumni_listing') . ' WHERE lid = ' . $item_id . ' LIMIT 1';
0 ignored issues
show
$item_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.

Loading history...
65
            $result       = $xoopsDB->query($sql);
66
            $result_array = $xoopsDB->fetchArray($result);
0 ignored issues
show
$result_array 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.

Loading history...
67
            $item['name'] = $result_array['title'];
0 ignored issues
show
$result_array 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.

Loading history...
68
            $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/listing.php?lid= ' . $item_id;
0 ignored issues
show
$item_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.

Loading history...
69
70
            return $item;
71
        }
72
73
        return $item;
74
    }
75
76
    /**
77
     * @return array
78
     */
79
    public function categories()
80
    {
81
        Xoops::getInstance()->loadLocale('alumni');
82
        $ret                      = [];
83
        $ret[1]['name']           = 'global';
84
        $ret[1]['title']          = AlumniLocale::NOTIFICATION_GLOBAL;
85
        $ret[1]['description']    = AlumniLocale::NOTIFICATION_GLOBAL_DSC;
86
        $ret[1]['subscribe_from'] = ['index.php', 'categories.php'];
87
88
        $ret[2]['name']           = 'category';
89
        $ret[2]['title']          = AlumniLocale::NOTIFICATION_CATEGORY;
90
        $ret[2]['description']    = AlumniLocale::NOTIFICATION_CATEGORY_DSC;
91
        $ret[2]['subscribe_from'] = ['categories.php'];
92
        $ret[2]['item_name']      = 'cid';
93
        $ret[2]['allow_bookmark'] = 1;
94
95
        $ret[3]['name']           = 'alumni_listing';
96
        $ret[3]['title']          = AlumniLocale::NOTIFICATION_ITEM;
97
        $ret[3]['description']    = AlumniLocale::NOTIFICATION_ITEM_DSC;
98
        $ret[3]['subscribe_from'] = ['listing.php'];
99
        $ret[3]['item_name']      = 'lid';
100
        $ret[3]['allow_bookmark'] = 1;
101
102
        return $ret;
103
    }
104
105
    /**
106
     * @return array
107
     */
108
    public function events()
109
    {
110
        $ret = [];
111
112
        //event
113
        //alumni notifications new listings in this category
114
        $ret[1]['name']          = 'new_listing';
115
        $ret[1]['category']      = 'category';
116
        $ret[1]['title']         = AlumniLocale::NOTIFICATION_GLOBAL_NEWLISTING;
117
        $ret[1]['caption']       = AlumniLocale::NOTIFICATION_CATEGORY_NEWLISTING_CAP;
118
        $ret[1]['description']   = AlumniLocale::NOTIFICATION_CATEGORY_NEWLISTING_DSC;
119
        $ret[1]['mail_template'] = 'listing_newpost_notify';
120
        $ret[1]['mail_subject']  = AlumniLocale::NOTIFICATION_GLOBAL_NEWLISTING_SBJ;
121
122
        //new listings in all categories posted
123
        $ret[2]['name']          = 'new_listing';
124
        $ret[2]['category']      = 'global';
125
        $ret[2]['title']         = AlumniLocale::NOTIFICATION_GLOBAL_NEWLISTING;
126
        $ret[2]['caption']       = AlumniLocale::NOTIFICATION_GLOBAL_NEWLISTING_CAP;
127
        $ret[2]['description']   = AlumniLocale::NOTIFICATION_GLOBAL_NEWLISTING_DSC;
128
        $ret[2]['mail_template'] = 'listing_newpost_notify';
129
        $ret[2]['mail_subject']  = AlumniLocale::NOTIFICATION_GLOBAL_NEWLISTING_SBJ;
130
131
        return $ret;
132
    }
133
134
    /**
135
     * @param string $category
136
     * @param int    $item_id
137
     * @param string $event
138
     *
139
     * @return array
140
     */
141
    public function tags($category, $item_id, $event)
0 ignored issues
show
$item_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.

Loading history...
142
    {
143
        return [];
144
    }
145
}
146