Issues (371)

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/Option.php (6 issues)

Labels
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Xoopspoll;
4
5
/*
6
               XOOPS - PHP Content Management System
7
                   Copyright (c) 2000-2020 XOOPS.org
8
                      <https://xoops.org>
9
 This program is free software; you can redistribute it and/or modify
10
 it under the terms of the GNU General Public License as published by
11
 the Free Software Foundation; either version 2 of the License, or
12
 (at your option) any later version.
13
14
 You may not change or alter any portion of this comment or credits
15
 of supporting developers from this source code or any supporting
16
 source code which is considered copyrighted (c) material of the
17
 original comment or credit authors.
18
19
 This program is distributed in the hope that it will be useful,
20
 but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 GNU General Public License for more details.
23
24
 You should have received a copy of the GNU General Public License
25
 along with this program; if not, write to the Free Software
26
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
27
*/
28
29
/**
30
 * Poll Option class for the XoopsPoll Module
31
 *
32
 * @copyright ::  {@link https://xoops.org/ XOOPS Project}
33
 * @license   ::  {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2.0 or later}
34
 * @subpackage::  class
35
 * @since     ::  1.0
36
 * @author    ::  {@link https://www.myweb.ne.jp/ Kazumi Ono (AKA onokazu)}
37
 */
38
39
use Criteria;
40
use XoopsModules\Xoopspoll\{
41
    Helper
0 ignored issues
show
This use statement conflicts with another class in this namespace, XoopsModules\Xoopspoll\Helper. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
42
};
43
use XoopsObject;
44
45
/**
46
 * Class Option
47
 */
48
class Option extends XoopsObject
49
{
50
    private int    $option_id;
0 ignored issues
show
The private property $option_id is not used, and could be removed.
Loading history...
51
    private int    $poll_id;
0 ignored issues
show
The private property $poll_id is not used, and could be removed.
Loading history...
52
    private string $option_text;
0 ignored issues
show
The private property $option_text is not used, and could be removed.
Loading history...
53
    private int    $option_count;
0 ignored issues
show
The private property $option_count is not used, and could be removed.
Loading history...
54
    private string $option_color;
0 ignored issues
show
The private property $option_color is not used, and could be removed.
Loading history...
55
    private mixed  $optHandler;
56
57
    /**
58
     * database connection object
59
     * @var \XoopsDatabasefactory
60
     */
61
    //    protected $db;
62
    /**
63
     * holds option object
64
     * @var Option
65
     */
66
    protected Option $option;
67
    /**
68
     * Option Handler to be used to manipulate poll options
69
     * @var OptionHandler
70
     */
71
    protected OptionHandler $optionHandler;
72
    // constructor
73
74
    /**
75
     * @param int|array|null $id poll id
76
     */
77
    public function __construct($id = null)
78
    {
79
        parent::__construct();
80
        //        $this->db = \XoopsDatabaseFactory::getDatabaseConnection();
81
        $this->initVar('option_id', \XOBJ_DTYPE_INT, null, false);
82
        $this->initVar('poll_id', \XOBJ_DTYPE_INT, null, true);
83
        $this->initVar('option_text', \XOBJ_DTYPE_TXTBOX, null, true, 255);
84
        $this->initVar('option_count', \XOBJ_DTYPE_INT, 0, false);
85
        $this->initVar('option_color', \XOBJ_DTYPE_OTHER, null, false);
86
87
        /**
88
         * {@internal The following is provided for backward compatibility with newbb/xforum}
89
         */
90
        $this->optHandler = $this->getStaticOptHandler();
91
        if (null !== $id) {
92
            if (\is_array($id)) {
93
                $this->option = $this->optHandler->create();
94
                $this->option->assignVars($id);
95
            } else {
96
                $this->option = $this->optHandler->get($id);
97
            }
98
        }
99
    }
100
101
    /**#@+
102
     * @deprecated since Xoopspoll 1.40, please @see OptionHandler & @see Option
103
     */
104
105
    /**
106
     * Stores object into the database
107
     * @return mixed
108
     * @uses       XoopsPersistableObjectHandler::insert
109
     * @deprecated since Xoopspoll 1.40, please @see XoopspollOptionHandler & @see XoopspollOption
110
     */
111
    public function store(): mixed
112
    {
113
        $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1);
114
        $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use Poll and PollHandler classes instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}");
115
116
        return $this->optHandler->insert($this->option);
117
    }
118
119
    /**
120
     * Delete all the poll options for a specific poll
121
     * @param int $pid is used to delete all options by this id
122
     * @return mixed results of deleting objects from database
123
     * @uses XoopsPersistableObjectHandler::deleteAll
124
     */
125
    public function deleteByPollId(int $pid): mixed
126
    {
127
        $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1);
128
        $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::deleteAll instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}");
129
        $criteria = new Criteria('poll_id', (int)$pid, '=');
130
131
        return $this->optHandler->deleteAll($criteria);
132
    }
133
134
    /**
135
     * Get all options for a particular poll
136
     * @param int $pid
137
     * @return mixed   results of getting objects from database
138
     * @uses XoopsPersistableObjectHandler::getAll
139
     */
140
    public function getAllByPollId(int $pid): mixed
141
    {
142
        $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1);
143
        $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::getAll instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}");
144
        $criteria = new Criteria('poll_id', (int)$pid, '=');
145
146
        return $this->optHandler->getAll($criteria);
147
    }
148
149
    /**
150
     * Reset the poll's options vote count
151
     * @param int $pid
152
     * @return mixed results of the object(s) update
153
     * @uses XoopsPersistableObjectHandler::updateAll
154
     */
155
    public function resetCountByPollId(int $pid): mixed
156
    {
157
        $trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1);
158
        $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __METHOD__ . ' is deprecated since Xoopspoll 1.40, please use PollHandler::updateAll instead.' . ". Called from {$trace[0]['file']}line {$trace[0]['line']}");
159
        $soptHandler = $this->getStaticOptHandler();
160
        $criteria    = new Criteria('poll_id', (int)$pid, '=');
161
162
        return $soptHandler->updateAll('option_count', 0, $criteria);
163
    }
164
165
    /**
166
     * Get a static Option Handler to be used to manipulate poll options
167
     * @return mixed handler object returned on success, false on failure
168
     * @uses xoops_getModuleHandler
169
     */
170
    private function getStaticOptHandler(): mixed
171
    {
172
        static $optionHandler;
173
174
        if (!isset($optionHandler)) {
175
            $optionHandler = Helper::getInstance()->getHandler('Option');
176
        }
177
178
        return $optionHandler;
179
    }
180
    /**#@-*/
181
}
182