This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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
|
|||
42 | }; |
||
43 | use XoopsObject; |
||
44 | |||
45 | /** |
||
46 | * Class Option |
||
47 | */ |
||
48 | class Option extends XoopsObject |
||
49 | { |
||
50 | private int $option_id; |
||
51 | private int $poll_id; |
||
52 | private string $option_text; |
||
53 | private int $option_count; |
||
54 | private string $option_color; |
||
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 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/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 beforeOtherDir/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: