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/alumni_tree.php (30 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 33 and the first side effect is on line 24.

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
/**
13
 * XOOPS tree class
14
 *
15
 * @copyright   XOOPS Project https://xoops.org/
16
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 * @package     class
18
 * @since       2.0.0
19
 * @author      Kazumi Ono (http://www.myweb.ne.jp/, http://jp.xoops.org/)
20
 * @author      Edited by John Mordo (jlm69)
21
 * @version     $Id$
22
 */
23
24
defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
25
26
/**
27
 * A tree structures with {@link XoopsObject}s as nodes
28
 *
29
 * @package    kernel
30
 * @subpackage core
31
 * @author     Kazumi Ono <[email protected]>
32
 */
33
class AlumniObjectTree extends XoopsObjectTree
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...
34
{
35
    /**
36
     * @var string
37
     */
38
    private $_parentId;
0 ignored issues
show
$_parentId 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...
39
40
    /**
41
     * @var string
42
     */
43
    private $_myId;
0 ignored issues
show
$_myId 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...
44
45
    /**
46
     * @var null|string
47
     */
48
    private $_rootId = null;
0 ignored issues
show
$_rootId 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...
49
50
    /**
51
     * @var array
52
     */
53
    private $_tree = [];
0 ignored issues
show
$_tree 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
55
    /**
56
     * @var array
57
     */
58
    private $_objects;
0 ignored issues
show
$_objects 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...
59
60
    /**
61
     * Constructor
62
     *
63
     * @param array  $objectArr Array of {@link XoopsObject}s
64
     * @param string $myId      field name of object ID
65
     * @param string $parentId  field name of parent object ID
66
     * @param string $rootId    field name of root object ID
0 ignored issues
show
Should the type for parameter $rootId not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
67
     */
68
    public function __construct(&$objectArr, $myId, $parentId, $rootId = null)
69
    {
70
        $this->_objects  = $objectArr;
71
        $this->_myId     = $myId;
72
        $this->_parentId = $parentId;
73
        if (null !== $rootId) {
74
            $this->_rootId = $rootId;
75
        }
76
        $this->_initialize();
77
    }
78
79
    /**
80
     * Initialize the object
81
     *
82
     * @access private
83
     */
84
    private function _initialize()
0 ignored issues
show
function _initialize() 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...
85
    {
86
        /* @var $object XoopsObject */
87
        foreach ($this->_objects as $object) {
88
            $key1                          = $object->getVar($this->_myId);
89
            $this->_tree[$key1]['obj']     = $object;
90
            $key2                          = $object->getVar($this->_parentId);
91
            $this->_tree[$key1]['parent']  = $key2;
92
            $this->_tree[$key2]['child'][] = $key1;
93
            if (null !== $this->_rootId) {
94
                $this->_tree[$key1]['root'] = $object->getVar($this->_rootId);
95
            }
96
        }
97
    }
98
99
    /**
100
     * Get the tree
101
     *
102
     * @return array Associative array comprising the tree
103
     */
104
    public function alumni_getTree()
0 ignored issues
show
function alumni_getTree() 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...
105
    {
106
        return $this->_tree;
107
    }
108
109
    /**
110
     * returns an object from the tree specified by its id
111
     *
112
     * @param  string $key ID of the object to retrieve
113
     * @return XoopsObject Object within the tree
114
     */
115
    public function alumni_getByKey($key)
0 ignored issues
show
function alumni_getByKey() 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...
116
    {
117
        return $this->_tree[$key]['obj'];
118
    }
119
120
    /**
121
     * returns an array of all the first child object of an object specified by its id
122
     *
123
     * @param  string $key ID of the parent object
124
     * @return array  Array of children of the parent
125
     */
126
    public function alumni_getFirstChild($key)
0 ignored issues
show
function alumni_getFirstChild() 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...
127
    {
128
        $ret = [];
129
        if (isset($this->_tree[$key]['child'])) {
130
            foreach ($this->_tree[$key]['child'] as $childkey) {
131
                $ret[$childkey] = $this->_tree[$childkey]['obj'];
132
            }
133
        }
134
135
        return $ret;
136
    }
137
138
    /**
139
     * returns an array of all child objects of an object specified by its id
140
     *
141
     * @param  string $key ID of the parent
142
     * @param  array  $ret (Empty when called from client) Array of children from previous recursions.
143
     * @return array  Array of child nodes.
144
     */
145
    public function alumni_getAllChild($key, $ret = [])
0 ignored issues
show
function alumni_getAllChild() 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...
146
    {
147
        if (isset($this->_tree[$key]['child'])) {
148
            foreach ($this->_tree[$key]['child'] as $childkey) {
149
                $ret[$childkey] = $this->_tree[$childkey]['obj'];
150
                $children       = $this->alumni_getAllChild($childkey, $ret);
151
                foreach (array_keys($children) as $newkey) {
152
                    $ret[$newkey] = $children[$newkey];
153
                }
154
            }
155
        }
156
157
        return $ret;
158
    }
159
160
    /**
161
     * returns an array of all parent objects.
162
     * the key of returned array represents how many levels up from the specified object
163
     *
164
     * @param  string $key     ID of the child object
165
     * @param  array  $ret     (empty when called from outside) Result from previous recursions
166
     * @param  int    $uplevel (empty when called from outside) level of recursion
167
     * @return array  Array of parent nodes.
168
     */
169
    public function alumni_getAllParent($key, $ret = [], $uplevel = 1)
0 ignored issues
show
function alumni_getAllParent() 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...
170
    {
171
        if (isset($this->_tree[$key]['parent']) && isset($this->_tree[$this->_tree[$key]['parent']]['obj'])) {
172
            $ret[$uplevel] = $this->_tree[$this->_tree[$key]['parent']]['obj'];
173
            $parents       = $this->alumni_getAllParent($this->_tree[$key]['parent'], $ret, $uplevel + 1);
174
            foreach (array_keys($parents) as $newkey) {
175
                $ret[$newkey] = $parents[$newkey];
176
            }
177
        }
178
179
        return $ret;
180
    }
181
182
    /**
183
     * Make options for a select box from
184
     *
185
     * @param string $fieldName   Name of the member variable from the
186
     *                            node objects that should be used as the title for the options.
187
     * @param string $selected    Value to display as selected
188
     * @param int    $key         ID of the object to display as the root of select options
189
     * @param string $ret         (reference to a string when called from outside) Result from previous recursions
190
     * @param string $prefix_orig String to indent items at deeper levels
191
     * @param string $prefix_curr String to indent the current item
192
     *
193
     * @return void
194
     */
195
    private function alumni_makeSelBoxOptions($fieldName, $selected, $key, &$ret, $prefix_orig, $prefix_curr = '')
0 ignored issues
show
function alumni_makeSelBoxOptions() 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...
$prefix_orig 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...
196
    {
197
        if ($key > 0) {
198
            /* @var $object XoopsObject */
199
            $object = $this->_tree[$key]['obj'];
200
            $value  = $object->getVar($this->_myId);
201
            $ret    .= '<option value="' . $value . '"';
202
            if ($value == $selected) {
203
                $ret .= ' selected="selected"';
204
            }
205
            $ret         .= '>' . $prefix_curr . $object->getVar($fieldName) . '</option>';
0 ignored issues
show
$prefix_curr 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...
206
            $prefix_curr .= $prefix_orig;
0 ignored issues
show
$prefix_curr 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...
207
        }
208 View Code Duplication
        if (isset($this->_tree[$key]['child']) && !empty($this->_tree[$key]['child'])) {
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...
209
            foreach ($this->_tree[$key]['child'] as $childkey) {
210
                $this->alumni_makeSelBoxOptions($fieldName, $selected, $childkey, $ret, $prefix_orig, $prefix_curr);
0 ignored issues
show
$prefix_orig 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...
211
            }
212
        }
213
    }
214
215
    /**
216
     * Make a select box with options from the tree
217
     *
218
     * @param          $name
219
     * @param  string  $fieldName      Name of the member variable from the
220
     *                                 node objects that should be used as the title for the options.
221
     * @param  string  $prefix         String to indent deeper levels
222
     * @param  string  $selected       Value to display as selected
223
     * @param  bool    $addEmptyOption Set TRUE to add an empty option with value "0" at the top of the hierarchy
224
     * @param  integer $key            ID of the object to display as the root of select options
225
     * @param  string  $extra
226
     * @return string  HTML select box
227
     */
228
    public function alumni_makeSelBox($name, $fieldName, $prefix = '-', $selected = '', $addEmptyOption = false, $key = 0, $extra = '')
0 ignored issues
show
function alumni_makeSelBox() 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...
229
    {
230
        $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...
231
        $ret   = '<select name="' . $name . '" id="' . $name . '" ' . $extra . '>';
232
        if (false != $addEmptyOption) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison !== instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
233
            $ret .= '<option value="0">' . XoopsLocale::ALL . '</option>';
234
        }
235
        $this->alumni_makeSelBoxOptions($fieldName, $selected, $key, $ret, $prefix);
236
237
        return $ret . '</select>';
238
    }
239
240
    /**
241
     * Make options for a array
242
     *
243
     * @param  string  $fieldName Name of the member variable from the
244
     *                            node objects that should be used as the column.
245
     * @param  string  $prefix    String to indent deeper levels
246
     * @param  integer $key       ID of the object to display as the root of the array
247
     * @return array
248
     */
249
    public function alumni_makeArrayTree($fieldName, $prefix = '-', $key = 0)
0 ignored issues
show
function alumni_makeArrayTree() 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...
250
    {
251
        $ret = [];
252
        $this->alumni_makeArrayTreeOptions($fieldName, $key, $ret, $prefix);
253
254
        return $ret;
255
    }
256
257
    /**
258
     * Make a array with options from the tree
259
     *
260
     * @param string  $fieldName   Name of the member variable from the
261
     *                             node objects that should be used as the column.
262
     * @param integer $key         ID of the object to display as the root of the array
263
     * @param         $ret
264
     * @param string  $prefix_orig String to indent deeper levels (origin)
265
     * @param string  $prefix_curr String to indent deeper levels (current)
266
     *
267
     * @return void
268
     */
269
    public function alumni_makeArrayTreeOptions($fieldName, $key, &$ret, $prefix_orig, $prefix_curr = '')
0 ignored issues
show
function alumni_makeArrayTreeOptions() 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...
$prefix_orig 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...
270
    {
271
        if ($key > 0) {
272
            $value       = $this->_tree[$key]['obj']->getVar($this->_myId);
273
            $ret[$value] = $prefix_curr . $this->_tree[$key]['obj']->getVar($fieldName);
0 ignored issues
show
$prefix_curr 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...
274
            $prefix_curr .= $prefix_orig;
0 ignored issues
show
$prefix_curr 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...
275
        }
276 View Code Duplication
        if (isset($this->_tree[$key]['child']) && !empty($this->_tree[$key]['child'])) {
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...
277
            foreach ($this->_tree[$key]['child'] as $childkey) {
278
                $this->alumni_makeArrayTreeOptions($fieldName, $childkey, $ret, $prefix_orig, $prefix_curr);
0 ignored issues
show
$prefix_orig 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...
279
            }
280
        }
281
    }
282
}
283