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/permission.php (29 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 34 and the first side effect is on line 29.

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
use Xoops\Core\Kernel\XoopsObjectHandler;
13
use Xoops\Core\Kernel\Criteria;
14
use Xoops\Core\Kernel\CriteriaCompo;
15
16
/**
17
 *  Alumni class
18
 *
19
 * @copyright       The XUUPS Project http://sourceforge.net/projects/xuups/
20
 * @license         GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
21
 * @package         Class
22
 * @subpackage      Handlers
23
 * @since           1.0
24
 * @author          trabis <[email protected]>
25
 * @author          The SmartFactory <www.smartfactory.ca>
26
 * @version         $Id$
27
 */
28
29
include_once dirname(__DIR__) . '/include/common.php';
30
31
/**
32
 * Class AlumniPermissionHandler
33
 */
34
class AlumniPermissionHandler extends XoopsObjectHandler
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...
35
{
36
    /**
37
     * @var Alumni
38
     * @access public
39
     */
40
    public $alumni = null;
41
42
    /**
43
     * constructor
44
     */
45
    public function __construct()
46
    {
47
        $this->alumni = Alumni::getInstance();
48
        $this->db2    = \Xoops::getInstance()->db();
49
    }
50
51
    /**
52
     * Returns permissions for a certain type
53
     *
54
     * @param string $gperm_name "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know)
55
     * @param int    $id         id of the item (forum, topic or possibly post) to get permissions for
56
     *
57
     * @return array
58
     */
59
    public function getGrantedGroupsById($gperm_name, $id)
0 ignored issues
show
$gperm_name 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...
60
    {
61
        static $items;
62
        if (isset($items[$gperm_name][$id])) {
0 ignored issues
show
$gperm_name 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...
63
            return $items[$gperm_name][$id];
0 ignored issues
show
$gperm_name 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...
64
        }
65
        $groups   = [];
66
        $criteria = new CriteriaCompo();
67
        $criteria->add(new Criteria('gperm_modid', $this->alumni->getModule()->getVar('mid')));
68
        $criteria->add(new Criteria('gperm_name', $gperm_name));
0 ignored issues
show
$gperm_name 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
        $criteria->add(new Criteria('gperm_itemid', $id));
70
        //Instead of calling groupperm handler and get objects, we will save some memory and do it our way
71
        $qb = $this->db2->createXoopsQueryBuilder();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $qb. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
72
        $qb->select('gperm_groupid')->fromPrefix('group_permission', '');
73
        $criteria->renderQb($qb);
74
        $result = $qb->execute();
75
76
        while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
77
            $groups[$myrow['gperm_groupid']] = $myrow['gperm_groupid'];
78
        }
79
        $items[$gperm_name][$id] = $groups;
0 ignored issues
show
$gperm_name 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...
80
        return $groups;
81
    }
82
83
    /**
84
     * Returns permissions for a certain type
85
     *
86
     * @param string $gperm_name "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know)
87
     *
88
     * @return array
89
     */
90
    public function getGrantedItems($gperm_name)
0 ignored issues
show
$gperm_name 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...
91
    {
92
        static $items;
93
        if (isset($items[$gperm_name])) {
0 ignored issues
show
$gperm_name 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...
94
            return $items[$gperm_name];
0 ignored issues
show
$gperm_name 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...
95
        }
96
        $ret = [];
97
        //Instead of calling groupperm handler and get objects, we will save some memory and do it our way
98
        $criteria = new CriteriaCompo(new Criteria('gperm_name', $gperm_name));
0 ignored issues
show
$gperm_name 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...
99
        $criteria->add(new Criteria('gperm_modid', $this->alumni->getModule()->getVar('mid')));
100
101
        //Get user's groups
102
        $groups    = \Xoops::getInstance()->getUserGroups();
103
        $criteria2 = new CriteriaCompo();
104
        foreach ($groups as $gid) {
105
            $criteria2->add(new Criteria('gperm_groupid', $gid), 'OR');
106
        }
107
        $criteria->add($criteria2);
108
109
        $qb = $this->db2->createXoopsQueryBuilder();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $qb. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
110
        $qb->select('gperm_itemid')->fromPrefix('group_permission', '');
111
        $criteria->renderQb($qb);
112
        $result = $qb->execute();
113
114
        while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) {
115
            $ret[$myrow['gperm_itemid']] = $myrow['gperm_itemid'];
116
        }
117
        $items[$gperm_name] = $ret;
0 ignored issues
show
$gperm_name 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...
118
        return $ret;
119
    }
120
121
    /**
122
     * isGranted
123
     *
124
     * @param string $gperm_name permission name
125
     * @param int    $id         item id
126
     *
127
     * @return bool
128
     */
129
    public function isGranted($gperm_name, $id)
0 ignored issues
show
$gperm_name 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...
130
    {
131
        if (!$id) {
132
            return false;
133
        }
134
        $permissions = $this->getGrantedItems($gperm_name);
0 ignored issues
show
$gperm_name 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...
135
        if (!empty($permissions) && isset($permissions[$id])) {
0 ignored issues
show
The if-else statement can be simplified to return !empty($permissio...set($permissions[$id]);.
Loading history...
136
            return true;
137
        } else {
138
            return false;
139
        }
140
    }
141
142
    /**
143
     * Saves permissions for the selected category
144
     *  saveCategory_Permissions()
145
     *
146
     * @param array   $groups    group with granted permission
147
     * @param integer $itemid    itemid on which we are setting permissions for Categories and Forums
148
     * @param string  $perm_name name of the permission
149
     *
150
     * @return boolean : TRUE if the no errors occured
151
     *
152
     * @todo is this used anywhere?
153
     */
154
    public function saveItemPermissions($groups, $itemid, $perm_name)
0 ignored issues
show
function saveItemPermissions() 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.

Loading history...
$perm_name 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...
155
    {
156
        $xoops         = Xoops::getInstance();
157
        $result        = true;
158
        $module_id     = $this->alumni->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.

Loading history...
159
        $gperm_handler = $xoops->getHandlerGroupPermission();
0 ignored issues
show
$gperm_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.

Loading history...
160
        // First, if the permissions are already there, delete them
161
        $gperm_handler->deleteByModule($module_id, $perm_name, $itemid);
0 ignored issues
show
$gperm_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.

Loading history...
162
        // Save the new permissions
163
        if (count($groups) > 0) {
164
            foreach ($groups as $group_id) {
0 ignored issues
show
$group_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...
165
                echo $group_id . '-';
0 ignored issues
show
$group_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...
166
                echo $gperm_handler->addRight($perm_name, $itemid, $group_id, $module_id);
0 ignored issues
show
$gperm_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.

Loading history...
167
            }
168
        }
169
        return $result;
170
    }
171
172
    /**
173
     * Delete all permission for a specific item
174
     *  deletePermissions()
175
     *
176
     * @param integer $itemid     id of the item for which to delete the permissions
177
     * @param string  $gperm_name permission name
178
     *
179
     * @return boolean : TRUE if the no errors occured
180
     */
181
    public function deletePermissions($itemid, $gperm_name)
0 ignored issues
show
function deletePermissions() 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.

Loading history...
$gperm_name 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...
182
    {
183
        $xoops         = Xoops::getInstance();
184
        $result        = true;
185
        $gperm_handler = $xoops->getHandlerGroupPermission();
0 ignored issues
show
$gperm_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.

Loading history...
186
        $gperm_handler->deleteByModule($this->alumni->getModule()->getVar('mid'), $gperm_name, $itemid);
0 ignored issues
show
$gperm_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.

Loading history...
187
        return $result;
188
    }
189
}
190