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 dictionary -> Lexikon // |
||
23 | // ------------------------------------------------------------------------ // |
||
24 | ////////////////////////////////////////////////////////////////////////////// |
||
25 | |||
26 | use Xmf\Request; |
||
27 | |||
28 | require_once __DIR__ . '/admin_header.php'; |
||
29 | $op = ''; |
||
30 | |||
31 | /**** |
||
32 | * Available operations |
||
33 | ****/ |
||
34 | switch ($op) { |
||
35 | case 'default': |
||
36 | default: |
||
37 | xoops_cp_header(); |
||
38 | global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig, $xoopsModule; |
||
39 | $myts = \MyTextSanitizer::getInstance(); |
||
40 | } |
||
41 | /**** |
||
42 | * Start Import |
||
43 | *** |
||
44 | * @param $msg |
||
45 | */ |
||
46 | function showerror($msg) |
||
47 | { |
||
48 | global $xoopsDB; |
||
49 | if ('' != $xoopsDB->error()) { |
||
50 | echo '<br>' . $msg . ' <br><span style="font-size: xx-small; "> - ' . _AM_LEXIKON_IMPORT_ERROR . ': ' . $xoopsDB->error() . '</span>.'; |
||
51 | } else { |
||
52 | echo '<br>' . $msg . '' . _AM_LEXIKON_IMPORT_OK; |
||
53 | } |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @param $text |
||
58 | * @return array|string|string[]|null |
||
59 | */ |
||
60 | function import2db($text) |
||
61 | { |
||
62 | return preg_replace(["/'/i"], ["\'"], $text); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @param $delete |
||
67 | */ |
||
68 | function DefinitionImport($delete) |
||
69 | { |
||
70 | global $xoopsConfig, $xoopsDB, $xoopsModule, $myts; |
||
71 | $sqlQuery = $xoopsDB->query('SELECT count(id) AS count FROM ' . $xoopsDB->prefix('dictionary')); |
||
72 | [$count] = $xoopsDB->fetchRow($sqlQuery); |
||
73 | if ($count < 1) { |
||
74 | redirect_header('import.php', 1, _AM_LEXIKON_MODULEIMPORTEMPTY10); |
||
75 | } |
||
76 | |||
77 | $delete = 0; |
||
78 | $glocounter = 0; |
||
79 | $errorcounter = 0; |
||
80 | |||
81 | if (isset($delete)) { |
||
82 | $delete = \Xmf\Request::getInt('delete', 0, 'POST'); |
||
83 | } else { |
||
84 | if (isset($delete)) { |
||
85 | $delete = \Xmf\Request::getInt('delete', 0, 'POST'); |
||
86 | } |
||
87 | } |
||
88 | |||
89 | /**** |
||
90 | * delete all entries and categories |
||
91 | ****/ |
||
92 | if ($delete) { |
||
93 | // delete notifications |
||
94 | xoops_notification_deletebymodule($xoopsModule->getVar('mid')); |
||
95 | //get all entries |
||
96 | $result3 = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . ' '); |
||
97 | //now for each entry, delete the coments |
||
98 | while (list($entryID) = $xoopsDB->fetchRow($result3)) { |
||
99 | xoops_comment_delete($xoopsModule->getVar('mid'), $entryID); |
||
100 | } |
||
101 | $resultC = $xoopsDB->query('SELECT categoryID FROM ' . $xoopsDB->prefix('lxcategories') . ' '); |
||
102 | while (list($categoryID) = $xoopsDB->fetchRow($resultC)) { |
||
103 | // delete permissions |
||
104 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_view', $categoryID); |
||
105 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_submit', $categoryID); |
||
106 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_approve', $categoryID); |
||
107 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_request', $categoryID); |
||
108 | } |
||
109 | // delete everything |
||
110 | $sqlquery1 = $xoopsDB->queryF('TRUNCATE TABLE ' . $xoopsDB->prefix('lxentries')); |
||
111 | $sqlquery2 = $xoopsDB->queryF('TRUNCATE TABLE ' . $xoopsDB->prefix('lxcategories')); |
||
112 | } |
||
113 | |||
114 | /**** |
||
115 | * Import ENTRIES |
||
116 | ****/ |
||
117 | |||
118 | $sql1 = $xoopsDB->query( |
||
119 | ' |
||
120 | SELECT * |
||
121 | FROM ' . $xoopsDB->prefix('dictionary') . ' ' |
||
122 | ); |
||
123 | |||
124 | $result1 = $xoopsDB->getRowsNum($sql1); |
||
125 | if ($result1) { |
||
126 | $fecha = time() - 1; |
||
127 | while (false !== ($row2 = $xoopsDB->fetchArray($sql1))) { |
||
128 | $entryID = (int)$row2['id']; |
||
129 | $init = $myts->addSlashes($row2['letter']); |
||
130 | $term = $myts->addSlashes(import2db($row2['name'])); |
||
131 | $definition = $myts->addSlashes(import2db($row2['definition'])); |
||
132 | $datesub = ++$fecha; |
||
133 | $estado = import2db($row2['state']); |
||
134 | if ('O' === $estado) { |
||
135 | $row2['state'] = 0; |
||
136 | } else { |
||
137 | $row2['state'] = 1; |
||
138 | } |
||
139 | if ('D' === $estado) { |
||
140 | $row2['submit'] = 1 && $row2['state'] = 1; |
||
141 | } else { |
||
142 | $row2['submit'] = 0; |
||
143 | } |
||
144 | $comments = (int)$row2['comments']; |
||
145 | ++$glocounter; |
||
146 | |||
147 | if ($delete) { |
||
148 | $ret1 = $xoopsDB->queryF( |
||
149 | ' |
||
150 | INSERT INTO ' . $xoopsDB->prefix('lxentries') . " |
||
151 | (entryID, init, term, definition, url, submit, datesub, offline, comments) |
||
152 | VALUES |
||
153 | ('$entryID', '$init', '$term', '$definition', '', '" . $row2['submit'] . "', '$datesub', '" . $row2['state'] . "', '$comments' )" |
||
154 | ); |
||
155 | } else { |
||
156 | $ret1 = $xoopsDB->queryF( |
||
157 | ' |
||
158 | INSERT INTO ' . $xoopsDB->prefix('lxentries') . " |
||
159 | (entryID, init, term, definition, url, submit, datesub, offline, comments) |
||
160 | VALUES |
||
161 | ('', '$init', '$term', '$definition', '', '" . $row2['submit'] . "', '$datesub', '" . $row2['state'] . "', '$comments' )" |
||
162 | ); |
||
163 | } |
||
164 | if (!$ret1) { |
||
165 | ++$errorcounter; |
||
166 | showerror('<br>' . _AM_LEXIKON_IMPORT_ERROR_IMPORT_TERM . ': <span style="color:red">entryID: ' . $entryID . '</span>: ' . $term . ' ...'); |
||
167 | } |
||
168 | // update user posts count |
||
169 | if ($ret1) { |
||
170 | if ($uid) { |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
171 | /** @var \XoopsMemberHandler $memberHandler */ |
||
172 | $memberHandler = xoops_getHandler('member'); |
||
173 | $submitter = $memberHandler->getUser($uid); |
||
174 | if (is_object($submitter)) { |
||
175 | $submitter->setVar('posts', $submitter->getVar('posts') + 1); |
||
176 | $res = $memberHandler->insertUser($submitter, true); |
||
177 | unset($submitter); |
||
178 | } |
||
179 | } |
||
180 | } |
||
181 | } |
||
182 | } |
||
183 | /**** |
||
184 | * FINISH |
||
185 | ****/ |
||
186 | |||
187 | $sqlQuery = $xoopsDB->query( |
||
188 | ' |
||
189 | SELECT mid FROM ' . $xoopsDB->prefix('modules') . " |
||
190 | WHERE dirname = 'dictionary'" |
||
191 | ); |
||
192 | [$dicID] = $xoopsDB->fetchRow($sqlQuery); |
||
193 | echo '<p>' . _AM_LEXIKON_IMPORT_MODULE_ID . ': ' . $dicID . '</p>'; |
||
194 | echo '<p>' . _AM_LEXIKON_IMPORT_MODULE_LEX_ID . ': ' . $xoopsModule->getVar('mid') . '</p><br>'; |
||
195 | |||
196 | $commentaire = $xoopsDB->queryF( |
||
197 | ' |
||
198 | UPDATE ' . $xoopsDB->prefix('xoopscomments') . " |
||
199 | SET com_modid = '" . $xoopsModule->getVar('mid') . "' |
||
200 | WHERE com_modid = '" . $dicID . "'" |
||
201 | ); |
||
202 | if (!$commentaire) { |
||
203 | showerror(_AM_LEXIKON_IMPORT_ERROR_IMPORT_COMMENT . ': ...'); |
||
204 | } else { |
||
205 | showerror(_AM_LEXIKON_IMPORT_COMMENT . ': '); |
||
206 | } |
||
207 | echo '<p>' . _AM_LEXIKON_IMPORT_UPDATE_COUNT . '</p>'; |
||
208 | echo "<p><span style='color:red'>" . _AM_LEXIKON_IMPORT_INCORRECTLY . ': ' . $errorcounter . '</span></p>'; |
||
209 | echo '<p>' . _AM_LEXIKON_IMPORT_PROCESSED . ': ' . $glocounter . '</p>'; |
||
210 | echo '<h3>' . _AM_LEXIKON_IMPORT_FINISH . '</h3>'; |
||
211 | echo "<br><b><a href='import.php'>" . _AM_LEXIKON_IMPORT_TO_ADMIN . '</a></b><p>'; |
||
212 | require_once __DIR__ . '/admin_footer.php'; |
||
213 | } |
||
214 | |||
215 | /**** |
||
216 | * IMPORT FORM PLAIN HTML |
||
217 | ****/ |
||
218 | |||
219 | function FormImport() |
||
220 | { |
||
221 | global $xoopsConfig, $xoopsDB, $xoopsModule; |
||
222 | //lx_importMenu(9); |
||
223 | echo "<strong style='color: #2F5376; margin-top:6px; font-size:medium'>" . _AM_LEXIKON_IMPORT_DICTIONARY . '</strong><br><br>'; |
||
224 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
225 | $moduleHandler = xoops_getHandler('module'); |
||
226 | $dictionaryModule = $moduleHandler->getByDirname('dictionary'); |
||
227 | $got_options = false; |
||
228 | if (is_object($dictionaryModule)) { |
||
229 | echo "<table style='width:100%; border:0;' class='outer'>"; |
||
230 | echo '<tr>'; |
||
231 | echo "<td colspan='2' class='bg3' style='text-align:left;'><span style='font-size:x-small;'><b>" . _AM_LEXIKON_MODULEHEADIMPORT . '</b></span></td>'; |
||
232 | echo '</tr>'; |
||
233 | |||
234 | echo '<tr>'; |
||
235 | 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>"; |
||
236 | echo "<td class='even' style='text-align:center;'><br><b><span style='font-size:x-small; color:red;'>" . _AM_LEXIKON_IMPORTWARN . '</span></b></td>'; |
||
237 | echo '</tr>'; |
||
238 | |||
239 | echo '<tr>'; |
||
240 | echo "<td class='head' style='width:200px; text-align:left'><span style='font-size:x-small;'>" . _AM_LEXIKON_IMPORTDELWB . '</span></td>'; |
||
241 | echo "<td class='even' style='text-align:center;'><form action='importdictionary.php?op=import' method=POST> |
||
242 | <input type='radio' name='delete' value='1'> " . _YES . " |
||
243 | <input type='radio' name='delete' value='0' checked> " . _NO . '</td>'; |
||
244 | echo "</tr><tr><td class='head' style='width:200px; text-align:center;'> </td>"; |
||
245 | echo "<td class='even' style='text-align:center;'> |
||
246 | <input type='submit' name='button' id='import' value='" . _AM_LEXIKON_IMPORT . "'> |
||
247 | <input type='button' name='cancel' value='" . _CANCEL . "' onclick='history.go(-1);'></td>"; |
||
248 | echo "</tr></table><br>\n"; |
||
249 | } else { |
||
250 | 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>'; |
||
251 | } |
||
252 | require_once __DIR__ . '/admin_footer.php'; |
||
253 | } |
||
254 | |||
255 | $op = Request::getCmd('op', ''); |
||
256 | switch ($op) { |
||
257 | case 'import': |
||
258 | $delete = Request::getInt('delete', 0); |
||
259 | DefinitionImport($delete); |
||
260 | break; |
||
261 | case 'main': |
||
262 | default: |
||
263 | FormImport(); |
||
264 | break; |
||
265 | } |
||
266 |