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 | XOOPS - PHP Content Management System |
||||
4 | Copyright (c) 2000-2020 XOOPS.org |
||||
5 | <https://xoops.org> |
||||
6 | This program is free software; you can redistribute it and/or modify |
||||
7 | it under the terms of the GNU General Public License as published by |
||||
8 | the Free Software Foundation; either version 2 of the License, or |
||||
9 | (at your option) any later version. |
||||
10 | |||||
11 | You may not change or alter any portion of this comment or credits |
||||
12 | of supporting developers from this source code or any supporting |
||||
13 | source code which is considered copyrighted (c) material of the |
||||
14 | original comment or credit authors. |
||||
15 | |||||
16 | This program is distributed in the hope that it will be useful, |
||||
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
19 | GNU General Public License for more details. |
||||
20 | |||||
21 | You should have received a copy of the GNU General Public License |
||||
22 | along with this program; if not, write to the Free Software |
||||
23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||||
24 | */ |
||||
25 | |||||
26 | /** |
||||
27 | * Administration menu for the XoopsPoll Module |
||||
28 | * |
||||
29 | * @copyright :: {@link https://xoops.org/ XOOPS Project} |
||||
30 | * @license :: {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2.0 or later} |
||||
31 | * @subpackage:: admin |
||||
32 | * @since :: 1.40 |
||||
33 | * @author :: XOOPS Module Team |
||||
34 | */ |
||||
35 | |||||
36 | use Xmf\Module\Admin; |
||||
37 | use Xmf\Request; |
||||
38 | use XoopsModules\Xoopspoll\{ |
||||
39 | Constants, |
||||
40 | Helper, |
||||
41 | Utility |
||||
42 | }; |
||||
43 | |||||
44 | require_once __DIR__ . '/admin_header.php'; |
||||
45 | |||||
46 | $helper = Helper::getInstance(); |
||||
47 | |||||
48 | $op = Request::getString('op', 'list'); |
||||
49 | switch ($op) { |
||||
50 | case 'list': |
||||
51 | default: |
||||
52 | xoops_cp_header(); |
||||
53 | $adminObject = Admin::getInstance(); |
||||
54 | |||||
55 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation(basename(__FILE__))); |
||||
56 | |||||
57 | $adminObject->addItemButton(_AM_XOOPSPOLL_IMPORT_UMFRAGE, 'utility.php' . '?op=umfrage', $icon = 'download'); |
||||
58 | $GLOBALS['xoopsTpl']->assign('addPollButton', $adminObject->displayButton('left')); |
||||
59 | |||||
60 | $GLOBALS['xoopsTpl']->assign('umfrageIntro', _AM_XOOPSPOLL_UMFRAGE_INTRO); |
||||
61 | $GLOBALS['xoopsTpl']->display($helper->path('templates/admin/xoopspoll_utility.tpl')); |
||||
62 | |||||
63 | require_once __DIR__ . '/admin_header.php'; |
||||
64 | break; |
||||
65 | /* Import data from umfrage */ |
||||
66 | case 'umfrage': |
||||
67 | $ok = Request::getString('ok', Constants::CONFIRM_NOT_OK, 'POST'); |
||||
68 | if ($ok) { |
||||
69 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
70 | redirect_header($_SERVER['SCRIPT_NAME'], Constants::REDIRECT_DELAY_MEDIUM, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
71 | } |
||||
72 | // first check to see if umfrage module is installed and active |
||||
73 | /** @var \XoopsModuleHandler $moduleHandler */ |
||||
74 | $moduleHandler = xoops_getHandler('module'); |
||||
75 | $umModule = $moduleHandler->getByDirname('umfrage'); |
||||
76 | |||||
77 | try { |
||||
78 | if (false !== $umModule && $umModule->isactive()) { |
||||
79 | // make sure the umfrage database tables exist |
||||
80 | /** @var \XoopsConfigHandler $configHandler */ |
||||
81 | $configHandler = xoops_getHandler('config'); |
||||
82 | $umModuleConfig = $configHandler->getConfigsByCat(0, $umModule->getVar('mid')); |
||||
83 | $success = false; |
||||
84 | $umTables = &$umModule->getInfo('tables'); |
||||
85 | foreach ($umTables as $umTable) { |
||||
86 | $s = Utility::dbTableExists($GLOBALS['xoopsDB'], $umTable); |
||||
87 | if (!$s) { |
||||
88 | throw new Exception("Could not find the umfrage db table ({$umTable})"); |
||||
89 | } |
||||
90 | } |
||||
91 | |||||
92 | //setup poll objects for both umfrage and xoopspoll |
||||
93 | require_once $GLOBALS['xoops']->path('modules/umfrage/class/umfrage.php'); |
||||
94 | require_once $GLOBALS['xoops']->path('modules/umfrage/class/umfrageoption.php'); |
||||
95 | require_once $GLOBALS['xoops']->path('modules/umfrage/class/umfragelog.php'); |
||||
96 | |||||
97 | $xpHandler = $helper->getHandler('Poll'); |
||||
98 | $xpOptHandler = $helper->getHandler('Option'); |
||||
99 | $xpLogHandler = $helper->getHandler('Log'); |
||||
100 | |||||
101 | // maps umfrage_desc : polltype to xoopspoll_desc : visibility |
||||
102 | $typeToVisMap = [ |
||||
103 | 1 => Constants::HIDE_NEVER, |
||||
104 | 2 => Constants::HIDE_ALWAYS, |
||||
105 | 3 => Constants::HIDE_VOTED, |
||||
106 | ]; |
||||
107 | |||||
108 | $err = []; |
||||
109 | $umContainer = new Umfrage(); |
||||
110 | $umOptContainer = new UmfrageOption(); |
||||
111 | $umLogContainer = new UmfrageLog(); |
||||
112 | $allUmfragePollObjs = $umContainer->getAll(); |
||||
113 | foreach ($allUmfragePollObjs as $umPollObj) { |
||||
114 | // make sure we don't have this question already (pretty strict comparison) |
||||
115 | $criteria = new \CriteriaCompo(); |
||||
116 | $criteria->add(new \Criteria('question', trim($umPollObj->getVar('question')), '=')); |
||||
117 | $criteria->setLimit(1); |
||||
118 | $pollExists = $xpHandler->getCount($criteria); |
||||
119 | if (0 === $pollExists) { |
||||
120 | // set the visibility for the poll |
||||
121 | if (array_key_exists((int)$umPollObj->getVar('polltype'), $typeToVisMap)) { |
||||
122 | $visibility = $typeToVisMap[$umPollObj->getVar('polltype')]; |
||||
123 | } else { |
||||
124 | $visibility = Constants::HIDE_END; |
||||
125 | } |
||||
126 | // save the poll into Xoopspoll database |
||||
127 | $xpValues = [ |
||||
128 | 'question' => $umPollObj->getVar('question'), |
||||
129 | 'description' => $umPollObj->getVar('description'), |
||||
130 | 'user_id' => $umPollObj->getVar('user_id'), |
||||
131 | 'start_time' => $umPollObj->getVar('start_time'), |
||||
132 | 'end_time' => $umPollObj->getVar('end_time'), |
||||
133 | 'votes' => (int)$umPollObj->getVar('votes'), |
||||
134 | 'voters' => (int)$umPollObj->getVar('voters'), |
||||
135 | 'multiple' => $umPollObj->getVar('multiple'), |
||||
136 | 'multilimit' => $umPollObj->getVar('multilimit'), |
||||
137 | 'display' => $umPollObj->getVar('display'), |
||||
138 | 'visibility' => $visibility, |
||||
139 | 'weight' => $umPollObj->getVar('weight'), |
||||
140 | 'mail_status' => $umPollObj->getVar('mail_status'), |
||||
141 | 'mail_voter' => $umPollObj->getVar('mail_voter'), |
||||
142 | ]; |
||||
143 | $xpObj = $xpHandler->create(); |
||||
144 | $xpObj->setVars($xpValues); |
||||
145 | $newXpId = $xpHandler->insert($xpObj); |
||||
146 | |||||
147 | if ($newXpId) { |
||||
148 | $optionIdMap = []; |
||||
149 | /* get the options for this poll and insert them */ |
||||
150 | $umOptObjs = $umOptContainer->getAllByPollId($umPollObj->getVar('poll_id')); |
||||
151 | if (!$umOptObjs) { |
||||
152 | throw new Exception('Could not find options for the ' . $umPollObj->getVar('question') . ' poll.'); |
||||
153 | } |
||||
154 | foreach ($umOptObjs as $umOptObj) { |
||||
155 | $optValues = [ |
||||
156 | 'poll_id' => $newXpId, |
||||
157 | 'option_text' => $umOptObj->getVar('option_text'), |
||||
158 | 'option_count' => $umOptObj->getVar('option_count'), |
||||
159 | 'option_color' => $umOptObj->getVar('option_color'), |
||||
160 | ]; |
||||
161 | $xpOptObj = $xpOptHandler->create(); |
||||
162 | $xpOptObj->setVars($optValues); |
||||
163 | $newXpOptId = $xpOptHandler->insert($xpOptObj); |
||||
164 | |||||
165 | if ($newXpOptId) { |
||||
166 | $newOptId = $newXpOptId; |
||||
167 | $oldOptId = $umOptObj->getVar('option_id'); |
||||
168 | $optionIdMap[$oldOptId] = $newOptId; |
||||
169 | } else { |
||||
170 | throw new Exception(sprintf(_AM_XOOPSPOLL_OPTION_FAILED, $umOptObj->getVar('option_text'), $umPollObj->getVar('question'), '<br>' . $xpOptObj->getHtmlErrors())); |
||||
171 | } |
||||
172 | } |
||||
173 | // now update the log for this poll |
||||
174 | $allUmfrageLogObjs = $umLogContainer->getAllByPollId($umPollObj->getVar('poll_id')); |
||||
175 | foreach ($allUmfrageLogObjs as $umLogObj) { |
||||
176 | $logValues = [ |
||||
177 | 'poll_id' => $newXpId, |
||||
178 | 'option_id' => $optionIdMap[$umLogObj->getVar('option_id')], |
||||
179 | 'ip' => $umLogObj->getVar('ip'), |
||||
180 | 'user_id' => $umLogObj->getVar('user_id'), |
||||
181 | 'time' => $umLogObj->getVar('time'), |
||||
182 | ]; |
||||
183 | $xpLogObj = $xpLogHandler->create(); |
||||
184 | $xpLogObj->setVars($logValues); |
||||
185 | $newLogId = $xpLogHandler->insert($xpLogObj); |
||||
186 | if (!$newLogId) { |
||||
187 | throw new Exception(sprintf(_AM_XOOPSPOLL_LOG_FAILED, $umPollObj->getVar('question') . '<br>' . $xpLogObj->getHtmlErrors())); |
||||
188 | } |
||||
189 | } |
||||
190 | unset($optionIdMap, $umOptObjs, $allUmfrageLogObjs); |
||||
191 | } else { |
||||
192 | throw new Exception(sprintf(_AM_XOOPSPOLL_QUESTION_FAILED, $umPollObj->getVar('question'), '<br>' . $xpObj->getHtmlErrors())); |
||||
193 | } |
||||
194 | } else { |
||||
195 | throw new Exception(sprintf(_AM_XOOPSPOLL_QUESTION_IMPORT_FAILED, $umPollObj->getVar('question'), '<br>' . $umPollObj->getHtmlErrors())); |
||||
196 | } |
||||
197 | unset($criteria, $umOptObjs); |
||||
198 | } |
||||
199 | redirect_header('index.php', Constants::REDIRECT_DELAY_MEDIUM, sprintf(_AM_XOOPSPOLL_IMPORT_SUCCESS, count($allUmfragePollObjs))); |
||||
200 | } else { |
||||
201 | throw new Exception(_AM_XOOPSPOLL_UMFRAGE_FAILED); |
||||
202 | } |
||||
203 | } catch (\Exception $e) { |
||||
204 | xoops_cp_header(); |
||||
205 | $adminObject = Admin::getInstance(); |
||||
206 | echo $adminObject->displayNavigation(basename(__FILE__)); |
||||
207 | echo "<div class='floatcenter1'>" . xoops_error($e->getMessage(), _AM_XOOPSPOLL_IMPORT_FAILED) . "</div>\n"; |
||||
0 ignored issues
–
show
Are you sure
xoops_error($e->getMessa...OOPSPOLL_IMPORT_FAILED) of type void can be used in concatenation ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
208 | require_once __DIR__ . '/admin_footer.php'; |
||||
209 | exit(); |
||||
210 | } |
||||
211 | } else { |
||||
212 | xoops_cp_header(); |
||||
213 | $adminObject = Admin::getInstance(); |
||||
214 | echo $adminObject->displayNavigation(basename(__FILE__)); |
||||
215 | xoops_confirm(['op' => 'umfrage', 'ok' => 1], $_SERVER['SCRIPT_NAME'], _AM_XOOPSPOLL_RUSUREUMFRAGE); |
||||
216 | require_once __DIR__ . '/admin_footer.php'; |
||||
217 | exit(); |
||||
218 | } |
||||
219 | break; |
||||
220 | } |
||||
221 | require_once __DIR__ . '/admin_footer.php'; |
||||
222 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.