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/Albums.php (5 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 Albums
11
 */
12
class Albums extends \XoopsObject
13
{
14
    /**
15
     * Albums constructor.
16
     * @param null $fid
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fid is correct as it would always require null to be passed?
Loading history...
17
     */
18
    public function __construct($fid = null)
19
    {
20
        $this->initVar('abid', \XOBJ_DTYPE_INT, 0, false);
21
        $this->initVar('cid', \XOBJ_DTYPE_INT, 0, false);
22
        $this->initVar('aids', \XOBJ_DTYPE_ARRAY, [], false);
23
        $this->initVar('sids', \XOBJ_DTYPE_ARRAY, [], false);
24
        $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128);
25
        $this->initVar('image', \XOBJ_DTYPE_TXTBOX, null, false, 255);
26
        $this->initVar('path', \XOBJ_DTYPE_TXTBOX, null, false, 255);
27
        $this->initVar('artists', \XOBJ_DTYPE_INT, 0, false);
28
        $this->initVar('songs', \XOBJ_DTYPE_INT, 0, false);
29
        $this->initVar('hits', \XOBJ_DTYPE_INT, 0, false);
30
        $this->initVar('rank', \XOBJ_DTYPE_DECIMAL, 0, false);
31
        $this->initVar('votes', \XOBJ_DTYPE_INT, 0, false);
32
        $this->initVar('created', \XOBJ_DTYPE_INT, 0, false);
33
        $this->initVar('updated', \XOBJ_DTYPE_INT, 0, false);
34
    }
35
36
    /**
37
     * @param bool $as_array
38
     * @return array|string
39
     */
40
    public function getForm($as_array = false)
41
    {
42
        return FormController::getFormAlbums($this, $as_array);
43
    }
44
45
    /**
46
     * @param bool $extra
47
     * @return array
48
     */
49
    public function toArray($extra = true): array
50
    {
51
        $ret  = parent::toArray();
52
        $form = $this->getForm(true);
53
        foreach ($form as $key => $element) {
54
            $ret['form'][$key] = $element->render();
55
        }
56
        foreach (['created', 'updated'] as $key) {
57
            if ($this->getVar($key) > 0) {
58
                $ret['form'][$key] = \date(_DATESTRING, $this->getVar($key));
59
                $ret[$key]         = \date(_DATESTRING, $this->getVar($key));
60
            }
61
        }
62
        $ret['picture'] = $this->getImage('image', false);
63
        $ret['rank']    = \number_format(($this->getVar('rank') > 0 && $this->getVar('votes') > 0 ? $this->getVar('rank') / $this->getVar('votes') : 0), 2) . \_MI_SONGLIST_OFTEN;
64
        $ret['url']     = $this->getURL(true);
0 ignored issues
show
The call to XoopsModules\Songlist\Albums::getURL() has too many arguments starting with true. ( Ignorable by Annotation )

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

64
        /** @scrutinizer ignore-call */ 
65
        $ret['url']     = $this->getURL(true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
65
66
        if (!$extra) {
67
            return $ret;
68
        }
69
70
        if (0 != $this->getVar('cid')) {
71
            $categoryHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Category');
72
            $category        = $categoryHandler->get($this->getVar('cid'));
73
            if (\is_object($category)) {
74
                $ret['category'] = $category->toArray(false);
0 ignored issues
show
The call to XoopsObject::toArray() has too many arguments starting with false. ( Ignorable by Annotation )

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

74
                /** @scrutinizer ignore-call */ 
75
                $ret['category'] = $category->toArray(false);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
75
            }
76
        }
77
78
        if (0 != \count($this->getVar('aids'))) {
0 ignored issues
show
It seems like $this->getVar('aids') can also be of type boolean and null and string; however, parameter $value of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

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

78
        if (0 != \count(/** @scrutinizer ignore-type */ $this->getVar('aids'))) {
Loading history...
79
            $artistsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Artists');
80
            foreach ($this->getVar('aids') as $aid) {
81
                $artist = $artistsHandler->get($aid);
82
                if (\is_object($artist)) {
83
                    $ret['artists_array'][$aid] = $artist->toArray(false);
84
                }
85
            }
86
        }
87
88
        if (0 != \count($this->getVar('sids'))) {
89
            $songsHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Songs');
90
            $criteria     = new \Criteria('sid', '(' . \implode(',', $this->getVar('sids')) . ')', 'IN');
0 ignored issues
show
It seems like $this->getVar('sids') can also be of type boolean and null and string; however, parameter $pieces of implode() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

90
            $criteria     = new \Criteria('sid', '(' . \implode(',', /** @scrutinizer ignore-type */ $this->getVar('sids')) . ')', 'IN');
Loading history...
91
            $criteria->setSort('traxid');
92
            $criteria->setOrder('ASC');
93
            foreach ($songsHandler->getObjects($criteria, true) as $sid => $song) {
94
                if (\is_object($song)) {
95
                    $ret['songs_array'][$sid] = $song->toArray(false);
96
                }
97
            }
98
        }
99
100
        return $ret;
101
    }
102
103
    /**
104
     * @param string $field
105
     * @param bool   $local
106
     * @return bool|string
107
     */
108
    public function getImage($field = 'image', $local = false)
109
    {
110
        if ('' == $this->getVar($field)) {
111
            return false;
112
        }
113
        if (!\file_exists($GLOBALS['xoops']->path($this->getVar('path') . $this->getVar($field)))) {
114
            return false;
115
        }
116
        if (!$local) {
117
            return XOOPS_URL . '/' . \str_replace(DS, '/', $this->getVar('path')) . $this->getVar($field);
118
        }
119
120
        return XOOPS_ROOT_PATH . DS . $this->getVar('path') . $this->getVar($field);
121
    }
122
123
    /**
124
     * @return string
125
     */
126
    public function getURL(): string
127
    {
128
        global $file, $op, $fct, $id, $value, $gid, $vid, $vcid, $cid, $start, $limit;
129
        if ($GLOBALS['songlistModuleConfig']['htaccess']) {
130
            if (0 != $id) {
131
                $artistHandler = \XoopsModules\Songlist\Helper::getInstance()->getHandler('Albums');
132
                $artist        = $artistHandler->get($id);
133
                if (\is_object($artist) && !$artist->isNew()) {
134
                    return XOOPS_URL
135
                           . '/'
136
                           . $GLOBALS['songlistModuleConfig']['baseofurl']
137
                           . '/albums/'
138
                           . \urlencode(\str_replace([' ', \chr(9)], '-', $artist->getVar('title')))
139
                           . '/'
140
                           . $start
141
                           . '-'
142
                           . $id
143
                           . '-'
144
                           . $op
145
                           . '-'
146
                           . $fct
147
                           . '-'
148
                           . $gid
149
                           . '-'
150
                           . $cid
151
                           . '/'
152
                           . \urlencode($value)
153
                           . $GLOBALS['songlistModuleConfig']['endofurl'];
154
                }
155
156
                return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
157
            }
158
159
            return XOOPS_URL . '/' . $GLOBALS['songlistModuleConfig']['baseofurl'] . '/albums/' . $start . '-' . $id . '-' . $op . '-' . $fct . '-' . $gid . '-' . $cid . '/' . \urlencode($value) . $GLOBALS['songlistModuleConfig']['endofurl'];
160
        }
161
162
        return XOOPS_URL . '/modules/songlist/albums.php?op=' . $op . '&fct=' . $fct . '&id=' . $id . '&value=' . \urlencode($value ?? '') . '&gid=' . $gid . '&vid=' . $vid . '&cid=' . $cid . '&start=' . $start;
163
    }
164
}
165