Issues (76)

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/MyiframeBaseHandler.php (16 issues)

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Myiframe;
4
5
/**
6
 * ****************************************************************************
7
 * MYIFRAME - MODULE FOR XOOPS
8
 * Copyright (c) Hervé Thouzard of Instant Zero (https://www.instant-zero.com)
9
 * ****************************************************************************
10
 */
11
require_once XOOPS_ROOT_PATH . '/kernel/object.php';
12
13
/**
14
 * Class MyiframeBaseHandler
15
 */
16
class MyiframeBaseHandler extends \XoopsObjectHandler
17
{
18
    /**
19
     * @param bool $isNew
20
     * @return \XoopsModules\Myiframe\MyiframeBase
21
     */
22
    public function create($isNew = true)
23
    {
24
        $object = new MyiframeBase();
25
        if ($isNew) {
26
            $object->setNew();
27
        }
28
29
        return $object;
30
    }
31
32
    /**
33
     * @param int $id
34
     * @return \XoopsModules\Myiframe\MyiframeBase|null
35
     */
36
    public function get($id)
37
    {
38
        $ret = null;
39
        $sql = 'SELECT * FROM ' . $this->db->prefix('myiframe') . '  WHERE frame_frameid=' . (int)$id;
40
        if (!$result = $this->db->query($sql)) {
41
            return $ret;
42
        }
43
        $numrows = $this->db->getRowsNum($result);
44
        if (1 == $numrows) {
45
            $object = new MyiframeBase();
46
            $object->assignVars($this->db->fetchArray($result));
47
48
            return $object;
49
        }
50
51
        return $ret;
52
    }
53
54
    /**
55
     * @param bool $force
56
     * @return bool
57
     */
58
    public function insert(\XoopsObject $object, $force = false)
59
    {
60
        if (!$object instanceof MyiframeBase) {
61
            return false;
62
        }
63
        if (!$object->isDirty()) {
64
            return true;
65
        }
66
        if (!$object->cleanVars()) {
67
            foreach ($object->getErrors() as $oneerror) {
68
                \trigger_error($oneerror);
69
            }
70
71
            return false;
72
        }
73
        foreach ($object->cleanVars as $k => $v) {
74
            ${$k} = $v;
75
        }
76
77
        if ($object->isNew()) {
78
            $format = 'INSERT INTO %s (frame_created, frame_uid, frame_description, frame_width, frame_height, frame_align, frame_frameborder, frame_marginwidth, frame_marginheight, frame_scrolling, frame_hits, frame_url) VALUES (%u, %u, %s, %s, %s, %d, %d, %d, %d, %d, %u, %s)';
79
            $sql    = \sprintf(
80
                $format,
81
                $this->db->prefix('myiframe'),
82
                $frame_created,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_created seems to be never defined.
Loading history...
83
                $frame_uid,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_uid does not exist. Did you maybe mean $frame_frameid?
Loading history...
84
                $this->db->quoteString($frame_description),
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_description seems to be never defined.
Loading history...
85
                $this->db->quoteString($frame_width),
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_width seems to be never defined.
Loading history...
86
                $this->db->quoteString($frame_height),
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_height seems to be never defined.
Loading history...
87
                $frame_align,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_align seems to be never defined.
Loading history...
88
                $frame_frameborder,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_frameborder does not exist. Did you maybe mean $frame_frameid?
Loading history...
89
                $frame_marginwidth,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_marginwidth seems to be never defined.
Loading history...
90
                $frame_marginheight,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_marginheight seems to be never defined.
Loading history...
91
                $frame_scrolling,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_scrolling seems to be never defined.
Loading history...
92
                $frame_hits,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_hits seems to be never defined.
Loading history...
93
                $this->db->quoteString($frame_url)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_url seems to be never defined.
Loading history...
94
            );
95
            $force  = true;
96
        } else {
97
            $format = 'UPDATE %s SET frame_description=%s, frame_width=%s, frame_height=%s, frame_align="%d", frame_frameborder="%d", frame_marginwidth="%d", frame_marginheight="%d", frame_scrolling="%d", frame_hits="%u", frame_url=%s WHERE frame_frameid=%u';
98
            $sql    = \sprintf(
99
                $format,
100
                $this->db->prefix('myiframe'),
101
                $this->db->quoteString($frame_description),
102
                $this->db->quoteString($frame_width),
103
                $this->db->quoteString($frame_height),
104
                $frame_align,
105
                $frame_frameborder,
106
                $frame_marginwidth,
107
                $frame_marginheight,
108
                $frame_scrolling,
109
                $frame_hits,
110
                $this->db->quoteString($frame_url),
111
                $frame_frameid
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_frameid seems to be never defined.
Loading history...
112
            );
113
        }
114
        if (false !== $force) {
115
            $result = $this->db->queryF($sql);
116
        } else {
117
            $result = $this->db->query($sql);
118
        }
119
        if (!$result) {
120
            return false;
121
        }
122
        if (empty($frame_frameid)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $frame_frameid seems to never exist and therefore empty should always be true.
Loading history...
123
            $frame_frameid = $this->db->getInsertId();
124
        }
125
        $object->assignVar('frame_frameid', $frame_frameid);
126
127
        return $frame_frameid;
128
    }
129
130
    /**
131
     * @param bool $force
132
     * @return bool
133
     */
134
    public function delete(\XoopsObject $object, $force = false)
135
    {
136
        if (!$object instanceof MyiframeBase) {
137
            return false;
138
        }
139
        $sql = \sprintf('DELETE FROM %s WHERE frame_frameid = "%u"', $this->db->prefix('myiframe'), $object->getVar('frame_frameid'));
0 ignored issues
show
It seems like $object->getVar('frame_frameid') can also be of type array and array; however, parameter $values of sprintf() does only seem to accept double|integer|string, 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

139
        $sql = \sprintf('DELETE FROM %s WHERE frame_frameid = "%u"', $this->db->prefix('myiframe'), /** @scrutinizer ignore-type */ $object->getVar('frame_frameid'));
Loading history...
140
        if (false !== $force) {
141
            $result = $this->db->queryF($sql);
142
        } else {
143
            $result = $this->db->query($sql);
144
        }
145
        if (!$result) {
146
            return false;
147
        }
148
149
        return true;
150
    }
151
152
    /**
153
     * @param \Criteria|null $criteria
154
     * @param bool           $id_as_key
155
     * @return array
156
     */
157
    public function &getObjects(\Criteria $criteria = null, $id_as_key = false): array
158
    {
159
        $ret   = [];
160
        $limit = $start = 0;
161
        $sql   = 'SELECT * FROM ' . $this->db->prefix('myiframe');
162
        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
163
            $sql .= ' ' . $criteria->renderWhere();
164
            if ('' !== $criteria->getSort()) {
165
                $sql .= ' ORDER BY ' . $criteria->getSort() . ' ' . $criteria->getOrder();
166
            }
167
            $limit = $criteria->getLimit();
168
            $start = $criteria->getStart();
169
        }
170
        $result = $this->db->query($sql, $limit, $start);
171
        /** @var array $myrow */
172
        if ($result instanceof \mysqli_result) {
173
            while (false !== ($myrow = $this->db->fetchArray($result))) {
174
                if (!$id_as_key) {
175
                    $ret[] = new MyiframeBase($myrow);
176
                } else {
177
                    $ret[$myrow['frame_frameid']] = new MyiframeBase($myrow);
178
                }
179
            }
180
        }
181
182
        return $ret;
183
    }
184
185
    /**
186
     * @param \CriteriaCompo|null $criteria
187
     * @return int
188
     */
189
    public function getCount(\CriteriaCompo $criteria = null): int
190
    {
191
        $sql = 'SELECT COUNT(*) FROM ' . $this->db->prefix('myiframe');
192
        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
193
            $sql .= ' ' . $criteria->renderWhere();
194
        }
195
        $result = $this->db->query($sql);
196
        if (!$result) {
197
            return 0;
198
        }
199
        [$count] = $this->db->fetchRow($result);
200
201
        return $count;
202
    }
203
204
    /**
205
     * @param \CriteriaCompo|null $criteria
206
     * @return bool
207
     */
208
    public function deleteAll(\CriteriaCompo $criteria = null): bool
209
    {
210
        $sql = 'DELETE FROM ' . $this->db->prefix('myiframe');
211
        if (($criteria instanceof \CriteriaCompo) || ($criteria instanceof \Criteria)) {
212
            $sql .= ' ' . $criteria->renderWhere();
213
        }
214
        if (!$result = $this->db->query($sql)) {
0 ignored issues
show
The assignment to $result is dead and can be removed.
Loading history...
215
            return false;
216
        }
217
218
        return true;
219
    }
220
221
    /**
222
     * @param $frame_id
223
     */
224
    public function updatehits($frame_id): void
225
    {
226
        $sql = \sprintf('UPDATE %s SET frame_hits = frame_hits+1 WHERE frame_frameid="%u"', $this->db->prefix('myiframe'), (int)$frame_id);
227
        $this->db->queryF($sql);
228
    }
229
}
230