XoopsModules25x /
lexikon
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 Wordbook -> Lexikon // |
||
| 23 | // ------------------------------------------------------------------------ // |
||
| 24 | ////////////////////////////////////////////////////////////////////////////// |
||
| 25 | |||
| 26 | use Xmf\Module\Admin; |
||
| 27 | use Xmf\Request; |
||
| 28 | |||
| 29 | require_once __DIR__ . '/admin_header.php'; |
||
| 30 | |||
| 31 | $op = ''; |
||
| 32 | |||
| 33 | /**** |
||
| 34 | * Available operations |
||
| 35 | ****/ |
||
| 36 | switch ($op) { |
||
| 37 | case 'default': |
||
| 38 | default: |
||
| 39 | xoops_cp_header(); |
||
| 40 | $adminObject = Admin::getInstance(); |
||
| 41 | $adminObject->displayNavigation(basename(__FILE__)); |
||
| 42 | |||
| 43 | global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig, $xoopsModule; |
||
| 44 | $myts = \MyTextSanitizer::getInstance(); |
||
| 45 | } |
||
| 46 | |||
| 47 | /**** |
||
| 48 | * Start Import |
||
| 49 | *** |
||
| 50 | * @param $msg |
||
| 51 | */ |
||
| 52 | |||
| 53 | function showerror($msg) |
||
| 54 | { |
||
| 55 | global $xoopsDB; |
||
| 56 | if ('' != $xoopsDB->error()) { |
||
| 57 | echo '<br>' . $msg . ' <br><span style="font-size: xx-small; "> - ' . _AM_LEXIKON_IMPORT_ERROR . ': ' . $xoopsDB->error() . '</span>.'; |
||
| 58 | } else { |
||
| 59 | echo '<br>' . $msg . '' . _AM_LEXIKON_IMPORT_OK; |
||
| 60 | } |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @param $text |
||
| 65 | * @return array|string|string[]|null |
||
| 66 | */ |
||
| 67 | function import2db($text) |
||
| 68 | { |
||
| 69 | return preg_replace(["/'/i"], ["\'"], $text); |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param $delete |
||
| 74 | */ |
||
| 75 | function DefinitionImport($delete) |
||
|
0 ignored issues
–
show
|
|||
| 76 | { |
||
| 77 | global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule, $entryID, $myts; |
||
| 78 | $sqlQuery = $xoopsDB->query('SELECT count(entryID) AS count FROM ' . $xoopsDB->prefix('wbentries')); |
||
| 79 | [$count] = $xoopsDB->fetchRow($sqlQuery); |
||
| 80 | if ($count < 1) { |
||
| 81 | redirect_header('import.php', 1, _AM_LEXIKON_MODULEIMPORTEMPTY10); |
||
| 82 | } |
||
| 83 | $delete = 0; |
||
| 84 | $wbkcounter = 0; |
||
| 85 | $errorcounter = 0; |
||
| 86 | $wbkcounter1 = 0; |
||
| 87 | |||
| 88 | if (isset($delete)) { |
||
| 89 | $delete = \Xmf\Request::getInt('delete', 0, 'POST'); |
||
| 90 | } else { |
||
| 91 | if (isset($delete)) { |
||
| 92 | $delete = \Xmf\Request::getInt('delete', 0, 'POST'); |
||
| 93 | } |
||
| 94 | } |
||
| 95 | |||
| 96 | /**** |
||
| 97 | * delete all entries and categories without comments |
||
| 98 | ****/ |
||
| 99 | if ($delete) { |
||
| 100 | // delete notifications |
||
| 101 | xoops_notification_deletebymodule($xoopsModule->getVar('mid')); |
||
| 102 | //get all entries |
||
| 103 | $resultE = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . ' '); |
||
| 104 | while (list($entryID) = $xoopsDB->fetchRow($resultE)) { |
||
| 105 | //delete comments for each entry |
||
| 106 | xoops_comment_delete($xoopsModule->getVar('mid'), $entryID); |
||
| 107 | } |
||
| 108 | $resultC = $xoopsDB->query('SELECT categoryID FROM ' . $xoopsDB->prefix('lxcategories') . ' '); |
||
| 109 | while (list($categoryID) = $xoopsDB->fetchRow($resultC)) { |
||
| 110 | // delete permissions |
||
| 111 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_view', $categoryID); |
||
| 112 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_submit', $categoryID); |
||
| 113 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_approve', $categoryID); |
||
| 114 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_request', $categoryID); |
||
| 115 | } |
||
| 116 | // delete everything |
||
| 117 | $sqlquery1 = $xoopsDB->queryF('TRUNCATE TABLE ' . $xoopsDB->prefix('lxentries')); |
||
|
0 ignored issues
–
show
|
|||
| 118 | $sqlquery2 = $xoopsDB->queryF('TRUNCATE TABLE ' . $xoopsDB->prefix('lxcategories')); |
||
|
0 ignored issues
–
show
|
|||
| 119 | } |
||
| 120 | |||
| 121 | /**** |
||
| 122 | * Import ENTRIES |
||
| 123 | ****/ |
||
| 124 | |||
| 125 | $sql1 = $xoopsDB->query( |
||
| 126 | ' |
||
| 127 | SELECT * |
||
| 128 | FROM ' . $xoopsDB->prefix('wbentries') . ' |
||
| 129 | ' |
||
| 130 | ); |
||
| 131 | $result1 = $xoopsDB->getRowsNum($sql1); |
||
| 132 | if ($result1) { |
||
| 133 | while (false !== ($row2 = $xoopsDB->fetchArray($sql1))) { |
||
| 134 | $entryID = (int)$row2['entryID']; |
||
| 135 | $categoryID = (int)$row2['categoryID']; |
||
| 136 | #$term = $myts -> addSlashes($row2['term']); |
||
| 137 | $term = $myts->addSlashes(import2db($row2['term'])); |
||
| 138 | $init = $myts->addSlashes($row2['init']); |
||
| 139 | $definition = $myts->addSlashes(import2db($row2['definition'])); |
||
| 140 | $ref = $myts->addSlashes($row2['ref']); |
||
| 141 | $url = $myts->addSlashes($row2['url']); |
||
| 142 | $uid = (int)$row2['uid']; |
||
| 143 | $submit = (int)$row2['submit']; |
||
| 144 | $datesub = (int)$row2['datesub']; |
||
| 145 | $counter = (int)$row2['counter']; |
||
| 146 | $html = (int)$row2['html']; |
||
| 147 | $smiley = (int)$row2['smiley']; |
||
| 148 | $xcodes = (int)$row2['xcodes']; |
||
| 149 | $breaks = (int)$row2['breaks']; |
||
| 150 | $block = (int)$row2['block']; |
||
| 151 | $offline = (int)$row2['offline']; |
||
| 152 | $notifypub = (int)$row2['notifypub']; |
||
| 153 | $request = (int)$row2['request']; |
||
| 154 | $comments = (int)$row2['comments']; |
||
| 155 | ++$wbkcounter; |
||
| 156 | |||
| 157 | if ($delete) { |
||
| 158 | $ret1 = $xoopsDB->queryF( |
||
| 159 | ' |
||
| 160 | INSERT INTO ' . $xoopsDB->prefix('lxentries') . " |
||
| 161 | (entryID, categoryID, term, init, definition, ref, url, uid, submit, datesub, counter, html, smiley, xcodes, breaks, block, offline, notifypub, request, comments) |
||
| 162 | VALUES |
||
| 163 | ('$entryID', '$categoryID', '$term', '$init', '$definition', '$ref', '$url', '$uid', '$submit', '$datesub', '$counter', '$html', '$smiley', '$xcodes', '$breaks', '$block', '$offline', '$notifypub', '$request', '$comments' )" |
||
| 164 | ); |
||
| 165 | } else { |
||
| 166 | $ret1 = $xoopsDB->queryF( |
||
| 167 | ' |
||
| 168 | INSERT INTO ' . $xoopsDB->prefix('lxentries') . " |
||
| 169 | (entryID, categoryID, term, init, definition, ref, url, uid, submit, datesub, counter, html, smiley, xcodes, breaks, block, offline, notifypub, request, comments) |
||
| 170 | VALUES |
||
| 171 | ('', '$categoryID', '$term', '$init', '$definition', '$ref', '$url', '$uid', '$submit', '$datesub', '$counter', '$html', '$smiley', '$xcodes', '$breaks', '$block', '$offline', '$notifypub', '$request', '$comments' )" |
||
| 172 | ); |
||
| 173 | } |
||
| 174 | if (!$ret1) { |
||
| 175 | ++$errorcounter; |
||
| 176 | showerror('<br>' . _AM_LEXIKON_IMPORT_ERROR_IMPORT_TERM . ': <span style="color:red">entryID: ' . $entryID . '</span>: ' . $term . ' ...'); |
||
| 177 | } |
||
| 178 | // update user posts count |
||
| 179 | if ($ret1) { |
||
| 180 | if ($uid) { |
||
| 181 | /** @var \XoopsMemberHandler $memberHandler */ |
||
| 182 | $memberHandler = xoops_getHandler('member'); |
||
| 183 | $submitter = $memberHandler->getUser($uid); |
||
| 184 | if (is_object($submitter)) { |
||
| 185 | $submitter->setVar('posts', $submitter->getVar('posts') + 1); |
||
| 186 | $res = $memberHandler->insertUser($submitter, true); |
||
|
0 ignored issues
–
show
|
|||
| 187 | unset($submitter); |
||
| 188 | } |
||
| 189 | } |
||
| 190 | } |
||
| 191 | } |
||
| 192 | } |
||
| 193 | |||
| 194 | /**** |
||
| 195 | * Import CATEGORIES |
||
| 196 | ****/ |
||
| 197 | |||
| 198 | $sql3 = $xoopsDB->query( |
||
| 199 | 'SELECT * |
||
| 200 | FROM ' . $xoopsDB->prefix('wbcategories') . ' |
||
| 201 | ORDER BY categoryID' |
||
| 202 | ); |
||
| 203 | |||
| 204 | $result3 = $xoopsDB->getRowsNum($sql3); |
||
| 205 | if ($result3) { |
||
| 206 | while (false !== ($row1 = $xoopsDB->fetchArray($sql3))) { |
||
| 207 | $categoryID = (int)$row1['categoryID']; |
||
| 208 | $name = $myts->addSlashes($row1['name']); |
||
| 209 | $description = $myts->addSlashes(import2db($row1['description'])); |
||
| 210 | $total = (int)$row1['total']; |
||
| 211 | $weight = (int)$row1['weight']; |
||
| 212 | ++$wbkcounter1; |
||
| 213 | |||
| 214 | // insert new field `` |
||
| 215 | if ($delete) { |
||
| 216 | $ret3 = $xoopsDB->queryF( |
||
| 217 | ' |
||
| 218 | INSERT INTO ' . $xoopsDB->prefix('lxcategories') . " |
||
| 219 | (categoryID, name, description, total, weight) |
||
| 220 | VALUES ('$categoryID','$name', '$description', '$total', '$weight')" |
||
| 221 | ); |
||
| 222 | } else { |
||
| 223 | $ret3 = $xoopsDB->queryF( |
||
| 224 | ' |
||
| 225 | INSERT INTO ' . $xoopsDB->prefix('lxcategories') . " |
||
| 226 | (categoryID, name, description, total, weight) |
||
| 227 | VALUES ('', '$name', '$description', '$total', '$weight')" |
||
| 228 | ); |
||
| 229 | } |
||
| 230 | if (!$ret3) { |
||
| 231 | ++$errorcounter; |
||
| 232 | showerror('<br>' . _AM_LEXIKON_IMPORT_ERROR_IMPORT_CAT . ': <span style="color:red">categoryID: ' . $categoryID . '</span>: ' . $name . ' ...'); |
||
| 233 | } |
||
| 234 | } |
||
| 235 | } |
||
| 236 | |||
| 237 | /**** |
||
| 238 | * FINISH |
||
| 239 | ****/ |
||
| 240 | |||
| 241 | $sqlquery4 = $xoopsDB->query( |
||
| 242 | ' |
||
| 243 | SELECT mid |
||
| 244 | FROM ' . $xoopsDB->prefix('modules') . " |
||
| 245 | WHERE dirname = 'wordbook'" |
||
| 246 | ); |
||
| 247 | [$wbkID] = $xoopsDB->fetchRow($sqlquery4); |
||
| 248 | |||
| 249 | echo '<p>' . _AM_LEXIKON_IMPORT_MODULE_ID . ': ' . $wbkID . '</p>'; |
||
| 250 | echo '<p>' . _AM_LEXIKON_IMPORT_MODULE_LEX_ID . ': ' . $xoopsModule->getVar('mid') . '<br>'; |
||
| 251 | |||
| 252 | $commentaire = $xoopsDB->queryF( |
||
| 253 | ' |
||
| 254 | UPDATE ' . $xoopsDB->prefix('xoopscomments') . " |
||
| 255 | SET com_modid = '" . $xoopsModule->getVar('mid') . "' |
||
| 256 | WHERE com_modid = '" . $wbkID . "'" |
||
| 257 | ); |
||
| 258 | |||
| 259 | if (!$commentaire) { |
||
| 260 | showerror(_AM_LEXIKON_IMPORT_ERROR_IMPORT_COMMENT . ': ...'); |
||
| 261 | } else { |
||
| 262 | showerror(_AM_LEXIKON_IMPORT_COMMENT . ': '); |
||
| 263 | } |
||
| 264 | echo '<p>' . _AM_LEXIKON_IMPORT_UPDATE_COUNT . '</p>'; |
||
| 265 | echo "<p><span style='color:red'>" . _AM_LEXIKON_IMPORT_INCORRECTLY . ': ' . $errorcounter . '</span></p>'; |
||
| 266 | echo '<p>' . _AM_LEXIKON_IMPORT_PROCESSED . ' Entries: ' . $wbkcounter . '</p>'; |
||
| 267 | echo '<p>' . _AM_LEXIKON_IMPORT_PROCESSED . ' Categories: ' . $wbkcounter1 . '</p>'; |
||
| 268 | echo '<h3>' . _AM_LEXIKON_IMPORT_FINISH . '</h3>'; |
||
| 269 | echo "<br><b><a href='import.php'>" . _AM_LEXIKON_IMPORT_TO_ADMIN . '</a></b><p>'; |
||
| 270 | require_once __DIR__ . '/admin_footer.php'; |
||
| 271 | } |
||
| 272 | |||
| 273 | /**** |
||
| 274 | * IMPORT FORM PLAIN HTML |
||
| 275 | ****/ |
||
| 276 | |||
| 277 | function FormImport() |
||
| 278 | { |
||
| 279 | global $xoopsConfig, $xoopsDB, $xoopsModule; |
||
| 280 | //lx_importMenu(9); |
||
| 281 | echo "<strong style='color: #2F5376; margin-top:6px; font-size:medium'>" . _AM_LEXIKON_IMPORT_WORDBOOK . '</strong><br><br>'; |
||
| 282 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 283 | $moduleHandler = xoops_getHandler('module'); |
||
| 284 | $wordbookModule = $moduleHandler->getByDirname('wordbook'); |
||
| 285 | $got_options = false; |
||
|
0 ignored issues
–
show
|
|||
| 286 | if (is_object($wordbookModule)) { |
||
| 287 | echo "<table style='width:100%; border:0;' class='outer'>"; |
||
| 288 | echo '<tr>'; |
||
| 289 | echo "<td colspan='2' class='bg3' style='text-align:left;'><span style='font-size: x-small; '><b>" . _AM_LEXIKON_MODULEHEADIMPORTWB . '</b></span></td>'; |
||
| 290 | echo '</tr>'; |
||
| 291 | |||
| 292 | echo '<tr>'; |
||
| 293 | 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>"; |
||
| 294 | echo "<td class='even' style='text-align:center;'><br><b><span style='font-size:x-small; color:red;'>" . _AM_LEXIKON_IMPORTWARN . '</span></b></td>'; |
||
| 295 | echo '</tr>'; |
||
| 296 | |||
| 297 | echo '<tr>'; |
||
| 298 | echo "<td class='head' style='width:200px; text-align:left'><span style='font-size:x-small;'>" . _AM_LEXIKON_IMPORTDELWB . '</span></td>'; |
||
| 299 | echo "<td class='even' style='text-align:center;'><form action='importdictionary.php?op=import' method=POST> |
||
| 300 | <input type='radio' name='delete' value='1'> " . _YES . " |
||
| 301 | <input type='radio' name='delete' value='0' checked> " . _NO . '</td>'; |
||
| 302 | echo "</tr><tr><td class='head' style='width:200px; text-align:center;'> </td>"; |
||
| 303 | echo "<td class='even' style='text-align:center;'> |
||
| 304 | <input type='submit' name='button' id='import' value='" . _AM_LEXIKON_IMPORT . "'> |
||
| 305 | <input type='button' name='cancel' value='" . _CANCEL . "' onclick='history.go(-1);'></td>"; |
||
| 306 | echo "</tr></table><br>\n"; |
||
| 307 | } else { |
||
| 308 | 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>'; |
||
| 309 | } |
||
| 310 | require_once __DIR__ . '/admin_footer.php'; |
||
| 311 | } |
||
| 312 | |||
| 313 | $op = Request::getCmd('op', ''); |
||
| 314 | |||
| 315 | switch ($op) { |
||
| 316 | case 'import': |
||
| 317 | $delete = \Xmf\Request::getInt('delete', \Xmf\Request::getInt('delete', 0, 'POST'), 'GET'); |
||
| 318 | DefinitionImport($delete); |
||
| 319 | break; |
||
| 320 | default: |
||
| 321 | FormImport(); |
||
| 322 | break; |
||
| 323 | } |
||
| 324 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.