Issues (388)

Security Analysis    not enabled

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

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/VoiceHandler.php (4 issues)

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Songlist;
4
5
require_once \dirname(__DIR__) . '/include/songlist.object.php';
6
// require_once \dirname(__DIR__) . '/include/songlist.form.php';
7
use  XoopsModules\Songlist\Form\FormController;
8
9
/**
10
 * Class VoiceHandler
11
 */
12
class VoiceHandler extends \XoopsPersistableObjectHandler
13
{
14
    /**
15
     * VoiceHandler constructor.
16
     * @param \XoopsDatabase $db
17
     */
18
    public function __construct(\XoopsDatabase $db)
19
    {
20
        parent::__construct($db, 'songlist_voice', Voice::class, 'vcid', 'name');
21
    }
22
23
    /**
24
     * @return array
25
     */
26
    public function filterFields(): array
27
    {
28
        return ['vcid', 'name', 'artists', 'albums', 'songs', 'hits', 'rank', 'votes', 'created', 'updated'];
29
    }
30
31
    /**
32
     * @param $filter
33
     * @return \CriteriaCompo
34
     */
35
    public function getFilterCriteria($filter): \CriteriaCompo
36
    {
37
        $parts    = \explode('|', $filter);
38
        $criteria = new \CriteriaCompo();
39
        foreach ($parts as $part) {
40
            $var = \explode(',', $part);
41
            if (!empty($var[1]) && !\is_numeric($var[0])) {
42
                $object = $this->create();
43
                if (\XOBJ_DTYPE_TXTBOX == $object->vars[$var[0]]['data_type']
44
                    || \XOBJ_DTYPE_TXTAREA == $object->vars[$var[0]]['data_type']) {
45
                    $criteria->add(new \Criteria('`' . $var[0] . '`', '%' . $var[1] . '%', ($var[2] ?? 'LIKE')));
46
                } elseif (in_array($object->vars[$var[0]]['data_type'], [XOBJ_DTYPE_INT, XOBJ_DTYPE_DECIMAL, XOBJ_DTYPE_FLOAT])) {
47
                    $criteria->add(new \Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '=')));
48
                } elseif (\XOBJ_DTYPE_ENUM == $object->vars[$var[0]]['data_type']) {
49
                    $criteria->add(new \Criteria('`' . $var[0] . '`', $var[1], ($var[2] ?? '=')));
50
                } elseif (\XOBJ_DTYPE_ARRAY == $object->vars[$var[0]]['data_type']) {
51
                    $criteria->add(new \Criteria('`' . $var[0] . '`', '%"' . $var[1] . '";%', ($var[2] ?? 'LIKE')));
52
                }
53
            } elseif (!empty($var[1]) && \is_numeric($var[0])) {
54
                $criteria->add(new \Criteria($var[0], $var[1]));
55
            }
56
        }
57
58
        return $criteria;
59
    }
60
61
    /**
62
     * @param        $filter
63
     * @param        $field
64
     * @param string $sort
65
     * @param string $op
66
     * @param string $fct
67
     * @return string
68
     */
69
    public function getFilterForm($filter, $field, $sort = 'created', $op = 'dashboard', $fct = 'list'): string
70
    {
71
        $ele = Utility::getFilterElement($filter, $field, $sort, $op, $fct);
72
        if (\is_object($ele)) {
73
            return $ele->render();
74
        }
75
76
        return '&nbsp;';
77
    }
78
79
    /**
80
     * @param bool $force
81
     * @return bool|mixed
82
     */
83
    public function insert(\XoopsObject $obj, $force = true)
84
    {
85
        if ($obj->isNew()) {
86
            $obj->setVar('created', \time());
87
        } else {
88
            $obj->setVar('updated', \time());
89
        }
90
        if ('' == $obj->getVar('name')) {
91
            return false;
92
        }
93
94
        return parent::insert($obj, $force);
95
    }
96
97
    public $_objects = ['object' => [], 'array' => []];
98
99
    /**
100
     * @param null $id
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $id is correct as it would always require null to be passed?
Loading history...
101
     * @param null $fields
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fields is correct as it would always require null to be passed?
Loading history...
102
     * @return \XoopsObject
103
     */
104
    public function get($id = null, $fields = null): \XoopsObject//get($id, $fields = '*')
105
    {
106
        $fields = $fields ?: '*';
0 ignored issues
show
$fields is of type null, thus it always evaluated to false.
Loading history...
107
        if (!isset($this->_objects['object'][$id])) {
108
            $this->_objects['object'][$id] = parent::get($id, $fields);
0 ignored issues
show
$fields of type string is incompatible with the type array expected by parameter $fields of XoopsPersistableObjectHandler::get(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

108
            $this->_objects['object'][$id] = parent::get($id, /** @scrutinizer ignore-type */ $fields);
Loading history...
109
            if (!isset($GLOBALS['songlistAdmin']) && \is_object($this->_objects['object'][$id])) {
110
                $sql = 'UPDATE `' . $this->table . '` set hits=hits+1 where `' . $this->keyName . '` = ' . $this->_objects['object'][$id]->getVar($this->keyName);
111
                $GLOBALS['xoopsDB']->queryF($sql);
112
            }
113
        }
114
115
        return $this->_objects['object'][$id];
116
    }
117
118
    /**
119
     * @param \CriteriaElement|\CriteriaCompo $criteria
120
     * @param bool $id_as_key
121
     * @param bool $as_object
122
     * @return array
123
     */
124
    public function &getObjects($criteria = null, $id_as_key = false, $as_object = true): array
125
    {
126
        $ret = parent::getObjects($criteria, $id_as_key, $as_object);
127
128
        /*if (!isset($GLOBALS['songlistAdmin'])) {
129
            $id = [];
130
            foreach($ret as $data) {
131
                if ($as_object==true) {
132
                    if (!in_array($data->getVar($this->keyName), array_keys($this->_objects['object']))) {
133
                        $this->_objects['object'][$data->getVar($this->keyName)] = $data;
134
                        $id[$data->getVar($this->keyName)] = $data->getVar($this->keyName);
135
                    }
136
                } else {
137
                    if (!in_array($data[$this->keyName], array_keys($this->_objects['array']))) {
138
                        $this->_objects['array'][$data[$this->keyName]] = $data;
139
                        $id[$data[$this->keyName]] = $data[$this->keyName];;
140
                    }
141
                }
142
            }
143
        }
144
        if (!isset($GLOBALS['songlistAdmin'])&&count($id)>0) {
145
            $sql = 'UPDATE `'.$this->table.'` set hits=hits+1 where `'.$this->keyName.'` IN ('.implode(',', $id).')';
146
            $GLOBALS['xoopsDB']->queryF($sql);
147
        }*/
148
149
        return $ret;
150
    }
151
152
    /**
153
     * @return string
154
     */
155
    public function getURL(): string
156
    {
157
        global $file, $op, $fct, $id, $value, $gid, $cid, $start, $limit;
158
        if ($GLOBALS['songlistModuleConfig']['htaccess']) {
159
            return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseurl'] . '/' . $file . '/' . $start . '-' . $op . '-' . $fct . '-' . $id . '-' . \urlencode($value) . '-' . $gid . '-' . $cid . $GLOBALS['songlistModuleConfig']['endofurl'];
160
        }
161
162
        return XOOPS_URL . '/modules/songlist/' . $file . '.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&cid=' . $cid . '&start=' . $start;
163
    }
164
165
    /**
166
     * @param int $limit
167
     * @return array
168
     */
169
    public function getTop($limit = 1): array
170
    {
171
        $sql     = 'SELECT * FROM `' . $this->table . '` WHERE `rank`>=0 ORDER BY (`rank`/`votes`) DESC LIMIT ' . $limit;
172
        $results = $GLOBALS['xoopsDB']->queryF($sql);
173
        $ret     = [];
174
        $i       = 0;
175
        while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($results))) {
176
            $ret[$i] = $this->create();
177
            $ret[$i]->assignVars($row);
178
            ++$i;
179
        }
180
181
        return $ret;
182
    }
183
184
    /**
185
     * @param \XoopsObject $object
186
     * @param bool         $force
187
     * @return bool
188
     */
189
    public function delete(\XoopsObject $object, $force = true): bool
190
    {
191
        parent::delete($object, $force);
192
        $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('songlist_songs') . ' SET `vcid` = 0 WHERE `vcid` = ' . $object->getVar('vcid');
193
194
        return $GLOBALS['xoopsDB']->queryF($sql);
195
    }
196
}
197