Issues (496)

Security Analysis    not enabled

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/TreeTable.php (4 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 namespace XoopsModules\Smartobject;
2
3
/**
4
 * Contains the classes responsible for displaying a tree table filled with records of SmartObjects
5
 *
6
 * @license    GNU
7
 * @author     marcan <[email protected]>
8
 * @link       http://smartfactory.ca The SmartFactory
9
 * @package    SmartObject
10
 * @subpackage SmartObjectTable
11
 */
12
13
use XoopsModules\Smartobject;
14
15
//require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
16
17
/**
18
 * SmartObjectTreeTable class
19
 *
20
 * Class representing a tree table for displaying SmartObjects
21
 *
22
 * @package SmartObject
23
 * @author  marcan <[email protected]>
24
 * @link    http://smartfactory.ca The SmartFactory
25
 */
26
class TreeTable extends Smartobject\BaseSmartObjectTable
27
{
28
    /**
29
     * SmartObjectTreeTable constructor.
30
     * @param PersistableObjectHandler $objectHandler
31
     * @param bool                     $criteria
32
     * @param array                    $actions
33
     * @param bool                     $userSide
34
     */
35
    public function __construct(
36
        PersistableObjectHandler $objectHandler,
37
        $criteria = false,
38
        $actions = ['edit', 'delete'],
39
        $userSide = false
40
    ) {
41
        $this->SmartObjectTable($objectHandler, $criteria, $actions, $userSide);
42
        $this->_isTree = true;
43
    }
44
45
    /**
46
     * Get children objects given a specific parentid
47
     *
48
     * @var    int $parentid id of the parent which children we want to retreive
49
     * @return array of SmartObject
50
     */
51
    public function getChildrenOf($parentid = 0)
52
    {
53
        return isset($this->_objects[$parentid]) ? $this->_objects[$parentid] : false;
54
    }
55
56
    /**
57
     * @param     $object
58
     * @param int $level
59
     */
60
    public function createTableRow($object, $level = 0)
61
    {
62
        $aObject = [];
63
64
        $i = 0;
65
66
        $aColumns        = [];
67
        $doWeHaveActions = false;
68
69
        foreach ($this->_columns as $column) {
70
            $aColumn = [];
71
72 View Code Duplication
            if (0 == $i) {
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...
73
                $class = 'head';
74
            } elseif (0 == $i % 2) {
75
                $class = 'even';
76
            } else {
77
                $class = 'odd';
78
            }
79
80
            if ($column->_customMethodForValue && method_exists($object, $column->_customMethodForValue)) {
81
                $method = $column->_customMethodForValue;
82
                $value  = $object->$method();
83 View Code Duplication
            } else {
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...
84
                /**
85
                 * If the column is the identifier, then put a link on it
86
                 */
87
                if ($column->getKeyName() == $this->_objectHandler->identifierName) {
88
                    $value = $object->getItemLink();
89
                } else {
90
                    $value = $object->getVar($column->getKeyName());
91
                }
92
            }
93
94
            $space = '';
95
            if ($column->getKeyName() == $this->_objectHandler->identifierName) {
96
                for ($i = 0; $i < $level; ++$i) {
97
                    $space .= '--';
98
                }
99
            }
100
101
            if ('' !== $space) {
102
                $space .= '&nbsp;';
103
            }
104
105
            $aColumn['value'] = $space . $value;
106
            $aColumn['class'] = $class;
107
            $aColumn['width'] = $column->getWidth();
108
            $aColumn['align'] = $column->getAlign();
109
            $aColumn['key']   = $column->getKeyName();
110
111
            $aColumns[] = $aColumn;
112
            ++$i;
113
        }
114
115
        $aObject['columns'] = $aColumns;
116
117
        $class            = 'even' === $class ? 'odd' : 'even';
118
        $aObject['class'] = $class;
119
120
        $actions = [];
121
122
        // Adding the custom actions if any
123
        foreach ($this->_custom_actions as $action) {
124
            if (method_exists($object, $action)) {
125
                $actions[] = $object->$action();
126
            }
127
        }
128
129
//        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjectcontroller.php';
130
        $controller = new ObjectController($this->_objectHandler);
131
132 View Code Duplication
        if (in_array('edit', $this->_actions)) {
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...
133
            $actions[] = $controller->getEditItemLink($object, false, true);
134
        }
135 View Code Duplication
        if (in_array('delete', $this->_actions)) {
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...
136
            $actions[] = $controller->getDeleteItemLink($object, false, true);
137
        }
138
        $aObject['actions'] = $actions;
139
140
        $this->_tpl->assign('smartobject_actions_column_width', count($actions) * 30);
141
        $aObject['id']     = $object->id();
142
        $this->_aObjects[] = $aObject;
143
144
        $childrenObjects = $this->getChildrenOf($object->id());
145
146
        $this->_hasActions = $this->_hasActions ? true : count($actions) > 0;
147
148
        if ($childrenObjects) {
149
            ++$level;
150
            foreach ($childrenObjects as $subObject) {
151
                $this->createTableRow($subObject, $level);
152
            }
153
        }
154
    }
155
156
    public function createTableRows()
157
    {
158
        $this->_aObjects = [];
159
160
        if (count($this->_objects) > 0) {
161
            foreach ($this->getChildrenOf() as $object) {
162
                $this->createTableRow($object);
163
            }
164
165
            $this->_tpl->assign('smartobject_objects', $this->_aObjects);
166
        } else {
167
            $colspan = count($this->_columns) + 1;
168
            $this->_tpl->assign('smartobject_colspan', $colspan);
169
        }
170
    }
171
172
    /**
173
     * @return mixed
174
     */
175
    public function fetchObjects()
176
    {
177
        $ret = $this->_objectHandler->getObjects($this->_criteria, 'parentid');
178
179
        return $ret;
180
    }
181
}
182