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 |
||
2 | ////////////////////////////////////////////////////////////////////////////// |
||
3 | // |
||
4 | // ------------------------------------------------------------------------ // |
||
5 | // This program is free software; you can redistribute it and/or modify // |
||
6 | // it under the terms of the GNU General Public License as published by // |
||
7 | // the Free Software Foundation; either version 2 of the License, or // |
||
8 | // (at your option) any later version. // |
||
9 | // // |
||
10 | // This program is distributed in the hope that it will be useful, but // |
||
11 | // WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // |
||
13 | // General Public License for more details. // |
||
14 | // // |
||
15 | // You should have received a copy of the GNU General Public License // |
||
16 | // along with this program; if not, write to the // |
||
17 | // Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, // |
||
18 | // MA 02111-1307 USA // |
||
19 | // ------------------------------------------------------------------------ // |
||
20 | // code partially from Aiba and rmdp // |
||
21 | // ------------------------------------------------------------------------ // |
||
22 | // import script XWords -> Lexikon // |
||
23 | // ------------------------------------------------------------------------ // |
||
24 | ////////////////////////////////////////////////////////////////////////////// |
||
25 | |||
26 | use Xmf\Request; |
||
27 | |||
28 | require_once __DIR__ . '/admin_header.php'; |
||
29 | |||
30 | $op = ''; |
||
31 | |||
32 | /**** |
||
33 | * Available operations |
||
34 | ****/ |
||
35 | switch ($op) { |
||
36 | case 'default': |
||
37 | default: |
||
38 | xoops_cp_header(); |
||
39 | global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig, $xoopsModule; |
||
40 | $myts = \MyTextSanitizer::getInstance(); |
||
41 | } |
||
42 | /**** |
||
43 | * Start Import |
||
44 | *** |
||
45 | * @param $msg |
||
46 | */ |
||
47 | |||
48 | function showerror($msg) |
||
49 | { |
||
50 | global $xoopsDB; |
||
51 | if ('' != $xoopsDB->error()) { |
||
52 | echo '<br>' . $msg . ' <br><span style="font-size: xx-small; "> - ' . _AM_LEXIKON_IMPORT_ERROR . ': ' . $xoopsDB->error() . '</span>.'; |
||
53 | } else { |
||
54 | echo '<br>' . $msg . '' . _AM_LEXIKON_IMPORT_OK; |
||
55 | } |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param $text |
||
60 | * @return array|string|string[]|null |
||
61 | */ |
||
62 | function import2db($text) |
||
63 | { |
||
64 | return preg_replace(["/'/i"], ["\'"], $text); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param $delete |
||
69 | */ |
||
70 | function DefinitionImport($delete) |
||
0 ignored issues
–
show
|
|||
71 | { |
||
72 | global $xoopsConfig, $xoopsDB, $xoopsModule; |
||
73 | $myts = \MyTextSanitizer::getInstance(); |
||
74 | $sqlQuery = $xoopsDB->query('SELECT count(entryID) AS count FROM ' . $xoopsDB->prefix('xwords_ent')); |
||
75 | [$count] = $xoopsDB->fetchRow($sqlQuery); |
||
76 | if ($count < 1) { |
||
77 | redirect_header('import.php', 1, _AM_LEXIKON_MODULEIMPORTEMPTY10); |
||
78 | } |
||
79 | |||
80 | $delete = 0; |
||
81 | $wxocounter = 0; |
||
82 | $errorcounter = 0; |
||
83 | $wxocounter1 = 0; |
||
84 | //$errorcounter1 = 0; |
||
85 | |||
86 | if (isset($delete)) { |
||
87 | $delete = \Xmf\Request::getInt('delete', 0, 'POST'); |
||
88 | } else { |
||
89 | if (isset($delete)) { |
||
90 | $delete = \Xmf\Request::getInt('delete', 0, 'POST'); |
||
91 | } |
||
92 | } |
||
93 | |||
94 | /**** |
||
95 | * delete all entries and categories. Xwords has no comments. |
||
96 | ****/ |
||
97 | if ($delete) { |
||
98 | // delete notifications |
||
99 | xoops_notification_deletebymodule($xoopsModule->getVar('mid')); |
||
100 | //get all entries |
||
101 | $result3 = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . ' '); |
||
102 | //delete comments for each entry |
||
103 | while (list($entryID) = $xoopsDB->fetchRow($result3)) { |
||
104 | xoops_comment_delete($xoopsModule->getVar('mid'), $entryID); |
||
105 | } |
||
106 | $resultC = $xoopsDB->query('SELECT categoryID FROM ' . $xoopsDB->prefix('lxcategories') . ' '); |
||
107 | while (list($categoryID) = $xoopsDB->fetchRow($resultC)) { |
||
108 | // delete permissions |
||
109 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_view', $categoryID); |
||
110 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_submit', $categoryID); |
||
111 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_approve', $categoryID); |
||
112 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_request', $categoryID); |
||
113 | } |
||
114 | // delete everything |
||
115 | $sqlquery1 = $xoopsDB->queryF('TRUNCATE TABLE ' . $xoopsDB->prefix('lxentries')); |
||
0 ignored issues
–
show
|
|||
116 | $sqlquery2 = $xoopsDB->queryF('TRUNCATE TABLE ' . $xoopsDB->prefix('lxcategories')); |
||
0 ignored issues
–
show
|
|||
117 | } |
||
118 | |||
119 | /**** |
||
120 | * Import ENTRIES |
||
121 | ****/ |
||
122 | |||
123 | $sql1 = $xoopsDB->query( |
||
124 | ' |
||
125 | SELECT * |
||
126 | FROM ' . $xoopsDB->prefix('xwords_ent') . ' ' |
||
127 | ); |
||
128 | |||
129 | $result1 = $xoopsDB->getRowsNum($sql1); |
||
130 | if ($result1) { |
||
131 | while (false !== ($row2 = $xoopsDB->fetchArray($sql1))) { |
||
132 | $entryID = (int)$row2['entryID']; |
||
133 | $categoryID = (int)$row2['categoryID']; |
||
134 | $term = $myts->addSlashes(import2db($row2['term'])); |
||
135 | $init = $myts->addSlashes($row2['init']); |
||
136 | $definition = $myts->addSlashes(import2db($row2['definition'])); |
||
137 | $ref = $myts->addSlashes($row2['ref']); |
||
138 | $url = $myts->addSlashes($row2['url']); |
||
139 | $uid = (int)$row2['uid']; |
||
140 | $submit = (int)$row2['submit']; |
||
141 | $datesub = (int)$row2['datesub']; |
||
142 | $counter = (int)$row2['counter']; |
||
143 | $html = (int)$row2['html']; |
||
144 | $smiley = (int)$row2['smiley']; |
||
145 | $xcodes = (int)$row2['xcodes']; |
||
146 | $breaks = (int)$row2['breaks']; |
||
147 | $block = (int)$row2['block']; |
||
148 | $offline = (int)$row2['offline']; |
||
149 | $notifypub = (int)$row2['notifypub']; |
||
150 | $request = (int)$row2['request']; |
||
151 | |||
152 | ++$wxocounter; |
||
153 | |||
154 | if ($delete) { |
||
155 | $ret1 = $xoopsDB->queryF( |
||
156 | ' |
||
157 | INSERT INTO ' . $xoopsDB->prefix('lxentries') . " |
||
158 | (entryID, categoryID, term, init, definition, ref, url, uid, submit, datesub, counter, html, smiley, xcodes, breaks, block, offline, notifypub, request) |
||
159 | VALUES |
||
160 | ('$entryID', '$categoryID', '$term', '$init', '$definition', '$ref', '$url', '$uid', '$submit', '$datesub', '$counter', '$html', '$smiley', '$xcodes', '$breaks', '$block', '$offline', '$notifypub', '$request' )" |
||
161 | ); |
||
162 | } else { |
||
163 | $ret1 = $xoopsDB->queryF( |
||
164 | ' |
||
165 | INSERT INTO ' . $xoopsDB->prefix('lxentries') . " |
||
166 | (entryID, categoryID, term, init, definition, ref, url, uid, submit, datesub, counter, html, smiley, xcodes, breaks, block, offline, notifypub, request) |
||
167 | VALUES |
||
168 | ('', '$categoryID', '$term', '$init', '$definition', '$ref', '$url', '$uid', '$submit', '$datesub', '$counter', '$html', '$smiley', '$xcodes', '$breaks', '$block', '$offline', '$notifypub', '$request' )" |
||
169 | ); |
||
170 | } |
||
171 | if (!$ret1) { |
||
172 | ++$errorcounter; |
||
173 | showerror('<br>' . _AM_LEXIKON_IMPORT_ERROR_IMPORT_TERM . ': <span style="color:red">entryID: ' . $entryID . '</span>: ' . $term . ' ...'); |
||
174 | } |
||
175 | // update user posts count |
||
176 | if ($ret1) { |
||
177 | if ($uid) { |
||
178 | /** @var \XoopsMemberHandler $memberHandler */ |
||
179 | $memberHandler = xoops_getHandler('member'); |
||
180 | $submitter = $memberHandler->getUser($uid); |
||
181 | if (is_object($submitter)) { |
||
182 | $submitter->setVar('posts', $submitter->getVar('posts') + 1); |
||
183 | $res = $memberHandler->insertUser($submitter, true); |
||
0 ignored issues
–
show
|
|||
184 | unset($submitter); |
||
185 | } |
||
186 | } |
||
187 | } |
||
188 | } |
||
189 | } |
||
190 | |||
191 | /**** |
||
192 | * Import CATEGORIES |
||
193 | ****/ |
||
194 | $sql2 = $xoopsDB->query( |
||
195 | 'SELECT * |
||
196 | FROM ' . $xoopsDB->prefix('xwords_cat') . ' |
||
197 | ORDER BY categoryID' |
||
198 | ); |
||
199 | |||
200 | $result2 = $xoopsDB->getRowsNum($sql2); |
||
201 | if ($result2) { |
||
202 | while (false !== ($row1 = $xoopsDB->fetchArray($sql2))) { |
||
203 | $categoryID = (int)$row1['categoryID']; |
||
204 | $name = $myts->addSlashes($row1['name']); |
||
205 | $description = $myts->addSlashes(import2db($row1['description'])); |
||
206 | $total = (int)$row1['total']; |
||
207 | $weight = (int)$row1['weight']; |
||
208 | ++$wxocounter1; |
||
209 | |||
210 | if ($delete) { |
||
211 | $ret2 = $xoopsDB->queryF( |
||
212 | ' |
||
213 | INSERT INTO ' . $xoopsDB->prefix('lxcategories') . " |
||
214 | (categoryID, name, description, total, weight) |
||
215 | VALUES ('$categoryID', '$name', '$description', '$total', '$weight')" |
||
216 | ); |
||
217 | } else { |
||
218 | $ret2 = $xoopsDB->queryF( |
||
219 | ' |
||
220 | INSERT INTO ' . $xoopsDB->prefix('lxcategories') . " |
||
221 | (categoryID, name, description, total, weight) |
||
222 | VALUES ('', '$name', '$description', '$total', '$weight')" |
||
223 | ); |
||
224 | } |
||
225 | if (!$ret2) { |
||
226 | ++$errorcounter; |
||
227 | showerror('<br>' . _AM_LEXIKON_IMPORT_ERROR_IMPORT_CAT . ': <span style="color:red">categoryID: ' . $categoryID . '</span>: ' . $name . ' ...'); |
||
228 | } |
||
229 | } |
||
230 | } |
||
231 | |||
232 | /**** |
||
233 | * FINISH |
||
234 | ****/ |
||
235 | |||
236 | $sqlQuery = $xoopsDB->query( |
||
237 | 'SELECT mid |
||
238 | FROM ' . $xoopsDB->prefix('modules') . " |
||
239 | WHERE dirname = 'xwords'" |
||
240 | ); |
||
241 | [$xwdID] = $xoopsDB->fetchRow($sqlQuery); |
||
242 | echo '<p>' . _AM_LEXIKON_IMPORT_MODULE_ID . ': ' . $xwdID . '</p>'; |
||
243 | echo '<p>' . _AM_LEXIKON_IMPORT_MODULE_LEX_ID . ': ' . $xoopsModule->getVar('mid') . '</p>'; |
||
244 | echo '<p>' . _AM_LEXIKON_IMPORT_UPDATE_COUNT . '</p>'; |
||
245 | echo "<p><span style='color:red'>" . _AM_LEXIKON_IMPORT_INCORRECTLY . ': ' . $errorcounter . '</span></p>'; |
||
246 | echo '<p>' . _AM_LEXIKON_IMPORT_PROCESSED . ': ' . $glocounter . '</p>'; |
||
247 | echo '<h3>' . _AM_LEXIKON_IMPORT_FINISH . '</h3>'; |
||
248 | echo "<br><b><a href='import.php'>" . _AM_LEXIKON_IMPORT_TO_ADMIN . '</a></b><p>'; |
||
249 | require_once __DIR__ . '/admin_footer.php'; |
||
250 | } |
||
251 | |||
252 | /**** |
||
253 | * IMPORT FORM PLAIN HTML |
||
254 | ****/ |
||
255 | |||
256 | function FormImport() |
||
257 | { |
||
258 | global $xoopsConfig, $xoopsDB, $xoopsModule; |
||
259 | //lx_importMenu(9); |
||
260 | echo "<strong style='color: #2F5376; margin-top:6px; font-size:medium'>" . _AM_LEXIKON_IMPORT_XWORDS . '</strong><br><br>'; |
||
261 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
262 | $moduleHandler = xoops_getHandler('module'); |
||
263 | $xwordsModule = $moduleHandler->getByDirname('xwords'); |
||
264 | $got_options = false; |
||
0 ignored issues
–
show
|
|||
265 | if (is_object($xwordsModule)) { |
||
266 | echo "<table style='width:100%; border:0;' class='outer'>"; |
||
267 | echo '<tr>'; |
||
268 | echo "<td colspan='2' class='bg3' style='text-align:left;'><span style='font-size: x-small; '><b>" . _AM_LEXIKON_MODULEHEADIMPORTXWO . '</b></span></td>'; |
||
269 | echo '</tr>'; |
||
270 | |||
271 | echo '<tr>'; |
||
272 | echo "<td class='head' style='width:200px; text-align:center;'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/assets/images/dialog-important.png' . "' alt='' style='margin-right:10px; margin-top:20px; text-align:middle;'></td>"; |
||
273 | echo "<td class='even' style='text-align:center;'><br><b><span style='font-size:x-small; color:red;'>" . _AM_LEXIKON_IMPORTWARN . '</span></b></td>'; |
||
274 | echo '</tr>'; |
||
275 | |||
276 | echo '<tr>'; |
||
277 | echo "<td class='head' style='width:200px; text-align:left'><span style='font-size:x-small;'>" . _AM_LEXIKON_IMPORTDELWB . '</span></td>'; |
||
278 | echo "<td class='even' style='text-align:center;'><form action='importdictionary.php?op=import' method=POST> |
||
279 | <input type='radio' name='delete' value='1'> " . _YES . " |
||
280 | <input type='radio' name='delete' value='0' checked> " . _NO . '</td>'; |
||
281 | echo "</tr><tr><td class='head' style='width:200px; text-align:center;'> </td>"; |
||
282 | echo "<td class='even' style='text-align:center;'> |
||
283 | <input type='submit' name='button' id='import' value='" . _AM_LEXIKON_IMPORT . "'> |
||
284 | <input type='button' name='cancel' value='" . _CANCEL . "' onclick='history.go(-1);'></td>"; |
||
285 | echo "</tr></table><br>\n"; |
||
286 | } else { |
||
287 | echo "<br><b><span style='color:red'>" . _AM_LEXIKON_IMPORT_ERROR_MODULE . "</span></b><br><br><a href='import.php'><button>" . _AM_LEXIKON_BACK . '</button></a>'; |
||
288 | } |
||
289 | require_once __DIR__ . '/admin_footer.php'; |
||
290 | } |
||
291 | |||
292 | global $op; |
||
293 | $op = Request::getCmd('op', ''); |
||
294 | |||
295 | switch ($op) { |
||
296 | case 'import': |
||
297 | $delete = \Xmf\Request::getInt('delete', \Xmf\Request::getInt('delete', 0, 'POST'), 'GET'); |
||
298 | DefinitionImport($delete); |
||
299 | break; |
||
300 | default: |
||
301 | FormImport(); |
||
302 | break; |
||
303 | } |
||
304 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.