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 glossaire -> Lexikon // |
||
| 23 | // ------------------------------------------------------------------------ // |
||
| 24 | ////////////////////////////////////////////////////////////////////////////// |
||
| 25 | |||
| 26 | use Xmf\Request; |
||
| 27 | |||
| 28 | require_once __DIR__ . '/admin_header.php'; |
||
| 29 | $myts = \MyTextSanitizer::getInstance(); |
||
| 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, $entryID; |
||
| 40 | $myts = \MyTextSanitizer::getInstance(); |
||
| 41 | } |
||
| 42 | |||
| 43 | /**** |
||
| 44 | * Start Import |
||
| 45 | *** |
||
| 46 | * @param $msg |
||
| 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 | $sqlQuery = $xoopsDB->query('SELECT count(id) AS count FROM ' . $xoopsDB->prefix('glossaire')); |
||
| 74 | [$count] = $xoopsDB->fetchRow($sqlQuery); |
||
| 75 | if ($count < 1) { |
||
| 76 | redirect_header('import.php', 1, _AM_LEXIKON_MODULEIMPORTEMPTY10); |
||
| 77 | } |
||
| 78 | |||
| 79 | $delete = 0; |
||
| 80 | $glocounter = 0; |
||
| 81 | $errorcounter = 0; |
||
| 82 | |||
| 83 | if (isset($delete)) { |
||
| 84 | $delete = \Xmf\Request::getInt('delete', 0, 'POST'); |
||
| 85 | } else { |
||
| 86 | if (isset($delete)) { |
||
| 87 | $delete = \Xmf\Request::getInt('delete', 0, 'POST'); |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | /**** |
||
| 92 | * delete all entries and categories without comments |
||
| 93 | ****/ |
||
| 94 | if ($delete) { |
||
| 95 | // delete notifications |
||
| 96 | xoops_notification_deletebymodule($xoopsModule->getVar('mid')); |
||
| 97 | //get all entries |
||
| 98 | $result3 = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . ' '); |
||
| 99 | //delete comments for each entry |
||
| 100 | while (list($entryID) = $xoopsDB->fetchRow($result3)) { |
||
| 101 | xoops_comment_delete($xoopsModule->getVar('mid'), $entryID); |
||
| 102 | } |
||
| 103 | $resultC = $xoopsDB->query('SELECT categoryID FROM ' . $xoopsDB->prefix('lxcategories') . ' '); |
||
| 104 | while (list($categoryID) = $xoopsDB->fetchRow($resultC)) { |
||
| 105 | // delete permissions |
||
| 106 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_view', $categoryID); |
||
| 107 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_submit', $categoryID); |
||
| 108 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_approve', $categoryID); |
||
| 109 | xoops_groupperm_deletebymoditem($xoopsModule->getVar('mid'), 'lexikon_request', $categoryID); |
||
| 110 | } |
||
| 111 | // delete everything |
||
| 112 | $sqlquery1 = $xoopsDB->queryF('TRUNCATE TABLE ' . $xoopsDB->prefix('lxentries')); |
||
|
0 ignored issues
–
show
|
|||
| 113 | $sqlquery2 = $xoopsDB->queryF('TRUNCATE TABLE ' . $xoopsDB->prefix('lxcategories')); |
||
|
0 ignored issues
–
show
|
|||
| 114 | } |
||
| 115 | |||
| 116 | /**** |
||
| 117 | * Import ENTRIES |
||
| 118 | ****/ |
||
| 119 | $sqlQuery = $xoopsDB->query( |
||
| 120 | 'SELECT id, lettre, nom, definition, affiche |
||
| 121 | FROM ' . $xoopsDB->prefix('glossaire') |
||
| 122 | ); |
||
| 123 | $fecha = time() - 1; |
||
| 124 | while (false !== ($sqlfetch = $xoopsDB->fetchArray($sqlQuery))) { |
||
| 125 | $glo = []; |
||
| 126 | $glo['id'] = $sqlfetch['id']; |
||
| 127 | $glo['lettre'] = $sqlfetch['lettre']; |
||
| 128 | $glo['nom'] = import2db($sqlfetch['nom']); |
||
| 129 | $glo['definition'] = import2db($sqlfetch['definition']); |
||
| 130 | $glo['affiche'] = ++$fecha; |
||
| 131 | |||
| 132 | ++$glocounter; |
||
| 133 | |||
| 134 | if ($delete) { |
||
| 135 | $insert = $xoopsDB->queryF( |
||
| 136 | ' |
||
| 137 | INSERT INTO ' . $xoopsDB->prefix('lxentries') . " |
||
| 138 | (entryID, init, term, definition, url, submit, datesub, offline, comments) |
||
| 139 | VALUES ('" . $glo['id'] . "','" . $glo['lettre'] . "','" . $glo['nom'] . "','" . $glo['definition'] . "','','','" . $glo['affiche'] . "','','')" |
||
| 140 | ); |
||
| 141 | } else { |
||
| 142 | $insert = $xoopsDB->queryF( |
||
| 143 | ' |
||
| 144 | INSERT INTO ' . $xoopsDB->prefix('lxentries') . " |
||
| 145 | (entryID, init, term, definition, url, submit, datesub, offline, comments) |
||
| 146 | VALUES ('','" . $glo['lettre'] . "','" . $glo['nom'] . "','" . $glo['definition'] . "','','','" . $glo['affiche'] . "','','')" |
||
| 147 | ); |
||
| 148 | } |
||
| 149 | if (!$insert) { |
||
| 150 | ++$errorcounter; |
||
| 151 | showerror('<br>' . _AM_LEXIKON_IMPORT_ERROR_IMPORT_TERM . ': <span style="color:red">entryID: ' . $glo['id'] . '</span>: ' . $glo['nom'] . ' ...'); |
||
| 152 | } |
||
| 153 | // update user posts count |
||
| 154 | if ($ret1) { |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 155 | if ($uid) { |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 156 | /** @var \XoopsMemberHandler $memberHandler */ |
||
| 157 | $memberHandler = xoops_getHandler('member'); |
||
| 158 | $submitter = $memberHandler->getUser($uid); |
||
| 159 | if (is_object($submitter)) { |
||
| 160 | $submitter->setVar('posts', $submitter->getVar('posts') + 1); |
||
| 161 | $res = $memberHandler->insertUser($submitter, true); |
||
|
0 ignored issues
–
show
|
|||
| 162 | unset($submitter); |
||
| 163 | } |
||
| 164 | } |
||
| 165 | } |
||
| 166 | } |
||
| 167 | |||
| 168 | $sqlQuery = $xoopsDB->query( |
||
| 169 | ' |
||
| 170 | SELECT mid |
||
| 171 | FROM ' . $xoopsDB->prefix('modules') . " |
||
| 172 | WHERE dirname = 'glossaire'" |
||
| 173 | ); |
||
| 174 | [$gloID] = $xoopsDB->fetchRow($sqlQuery); |
||
| 175 | echo '<p>' . _AM_LEXIKON_IMPORT_MODULE_ID . ': ' . $gloID . '</p>'; |
||
| 176 | echo '<p>' . _AM_LEXIKON_IMPORT_MODULE_LEX_ID . ': ' . $xoopsModule->getVar('mid') . '<br>'; |
||
| 177 | |||
| 178 | $comentario = $xoopsDB->queryF( |
||
| 179 | 'UPDATE ' . $xoopsDB->prefix('xoopscomments') . " |
||
| 180 | SET com_modid = '" . $xoopsModule->getVar('mid') . "' |
||
| 181 | WHERE com_modid = '" . $gloID . "'" |
||
| 182 | ); |
||
| 183 | if (!$comentario) { |
||
| 184 | showerror(_AM_LEXIKON_IMPORT_ERROR_IMPORT_COMMENT . ': ...'); |
||
| 185 | } else { |
||
| 186 | showerror(_AM_LEXIKON_IMPORT_COMMENT . ': '); |
||
| 187 | } |
||
| 188 | echo '<p>' . _AM_LEXIKON_IMPORT_UPDATE_COUNT . '</p>'; |
||
| 189 | echo "<p><span style='color:red'>" . _AM_LEXIKON_IMPORT_INCORRECTLY . ': ' . $errorcounter . '</span></p>'; |
||
| 190 | echo '<p>' . _AM_LEXIKON_IMPORT_PROCESSED . ': ' . $glocounter . '</p>'; |
||
| 191 | echo '<h3>' . _AM_LEXIKON_IMPORT_FINISH . '</h3>'; |
||
| 192 | echo "<br><b><a href='import.php'>" . _AM_LEXIKON_IMPORT_TO_ADMIN . '</a></b><p>'; |
||
| 193 | require_once __DIR__ . '/admin_footer.php'; |
||
| 194 | } |
||
| 195 | |||
| 196 | /**** |
||
| 197 | * IMPORT FORM |
||
| 198 | ****/ |
||
| 199 | function FormImport() |
||
| 200 | { |
||
| 201 | global $xoopsConfig, $xoopsDB, $xoopsModule; |
||
| 202 | //lx_importMenu(9); |
||
| 203 | echo "<strong style='color: #2F5376; margin-top:6px; font-size:medium'>" . _AM_LEXIKON_IMPORT_GLOSSAIRE . '</strong><br><br>'; |
||
| 204 | /** @var \XoopsModuleHandler $moduleHandler */ |
||
| 205 | $moduleHandler = xoops_getHandler('module'); |
||
| 206 | $glossaireModule = $moduleHandler->getByDirname('glossaire'); |
||
| 207 | $got_options = false; |
||
|
0 ignored issues
–
show
|
|||
| 208 | if (is_object($glossaireModule)) { |
||
| 209 | echo "<table style='width:100%; border:0;' class='outer'>"; |
||
| 210 | echo '<tr>'; |
||
| 211 | echo "<td colspan='2' class='bg3' style='text-align:left;'><span style='font-size: x-small; '><b>" . _AM_LEXIKON_MODULEHEADIMPORTGLO . '</b></span></td>'; |
||
| 212 | echo '</tr>'; |
||
| 213 | |||
| 214 | echo '<tr>'; |
||
| 215 | 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>"; |
||
| 216 | echo "<td class='even' style='text-align:center;'><br><b><span style='font-size:x-small; color:red;'>" . _AM_LEXIKON_IMPORTWARN . '</span></b></td>'; |
||
| 217 | echo '</tr>'; |
||
| 218 | |||
| 219 | echo '<tr>'; |
||
| 220 | echo "<td class='head' style='width:200px; text-align:left'><span style='font-size:x-small;'>" . _AM_LEXIKON_IMPORTDELWB . '</span></td>'; |
||
| 221 | echo "<td class='even' style='text-align:center;'><form action='importdictionary.php?op=import' method=POST> |
||
| 222 | <input type='radio' name='delete' value='1'> " . _YES . " |
||
| 223 | <input type='radio' name='delete' value='0' checked> " . _NO . '</td>'; |
||
| 224 | echo "</tr><tr><td class='head' style='width:200px; text-align:center;'> </td>"; |
||
| 225 | echo "<td class='even' style='text-align:center;'> |
||
| 226 | <input type='submit' name='button' id='import' value='" . _AM_LEXIKON_IMPORT . "'> |
||
| 227 | <input type='button' name='cancel' value='" . _CANCEL . "' onclick='history.go(-1);'></td>"; |
||
| 228 | echo "</tr></table><br>\n"; |
||
| 229 | } else { |
||
| 230 | 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>'; |
||
| 231 | } |
||
| 232 | require_once __DIR__ . '/admin_footer.php'; |
||
| 233 | } |
||
| 234 | |||
| 235 | global $op; |
||
| 236 | $op = Request::getCmd('op', ''); |
||
| 237 | switch ($op) { |
||
| 238 | case 'import': |
||
| 239 | $delete = \Xmf\Request::getInt('delete', \Xmf\Request::getInt('delete', 0, 'POST'), 'GET'); |
||
| 240 | DefinitionImport($delete); |
||
| 241 | break; |
||
| 242 | default: |
||
| 243 | FormImport(); |
||
| 244 | break; |
||
| 245 | } |
||
| 246 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.