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.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * **************************************************************************** |
||
4 | * - A Project by Developers TEAM For Xoops - ( https://xoops.org ) |
||
5 | * **************************************************************************** |
||
6 | * XNEWSLETTER - MODULE FOR XOOPS |
||
7 | * Copyright (c) 2007 - 2012 |
||
8 | * Goffy ( wedega.com ) |
||
9 | * |
||
10 | * You may not change or alter any portion of this comment or credits |
||
11 | * of supporting developers from this source code or any supporting |
||
12 | * source code which is considered copyrighted (c) material of the |
||
13 | * original comment or credit authors. |
||
14 | * |
||
15 | * This program is distributed in the hope that it will be useful, |
||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
18 | * GNU General Public License for more details. |
||
19 | * --------------------------------------------------------------------------- |
||
20 | * @copyright Goffy ( wedega.com ) |
||
21 | * @license GPL 2.0 |
||
22 | * @package xnewsletter |
||
23 | * @author Goffy ( [email protected] ) |
||
24 | * |
||
25 | * **************************************************************************** |
||
26 | */ |
||
27 | |||
28 | use Xmf\Request; |
||
29 | |||
30 | $currentFile = basename(__FILE__); |
||
31 | require_once __DIR__ . '/admin_header.php'; |
||
32 | xoops_cp_header(); |
||
33 | |||
34 | // set template |
||
35 | $templateMain = 'xnewsletter_admin_import.tpl'; |
||
36 | |||
37 | define('XNEWSLETTER_BASIC_LIMIT_IMPORT_CHECKED', 100); |
||
38 | define('XNEWSLETTER_BASIC_LIMIT_IMPORT_AT_ONCE', 10); |
||
39 | |||
40 | $op = Request::getString('op', 'default'); |
||
41 | $plugin = Request::getString('plugin', 'csv'); |
||
42 | $cat_id = Request::getInt('cat_id', 0, 'int'); |
||
43 | $action_after_read = Request::getInt('action_after_read', 1); |
||
44 | $start = Request::getInt('start', 0); |
||
45 | $limitcheck = Request::getInt('limitcheck', XNEWSLETTER_BASIC_LIMIT_IMPORT_CHECKED); |
||
46 | $skipcatsubscrexist = Request::getInt('skipcatsubscrexist', 1); |
||
47 | $check_import = Request::getInt('check_import', 0); |
||
48 | |||
49 | $adminObject->displayNavigation($currentFile); |
||
50 | |||
51 | switch ($op) { |
||
52 | case 'show_formcheck': |
||
53 | $adminObject->addItemButton(_AM_XNEWSLETTER_IMPORT_PLUGINS_AVAIL, $currentFile, 'list'); |
||
54 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left')); |
||
55 | |||
56 | $importCriteria = new \CriteriaCompo(); |
||
57 | $importCriteria->setSort('import_id'); |
||
58 | $importCriteria->setOrder('ASC'); |
||
59 | $importsCount = $helper->getHandler('Import')->getCount($importCriteria); |
||
60 | |||
61 | $importCriteria->setStart($start); |
||
62 | $importCriteria->setLimit($limitcheck); |
||
63 | $importObjs = $helper->getHandler('Import')->getAll($importCriteria); |
||
64 | |||
65 | if ($importsCount > 0) { |
||
66 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
67 | |||
68 | $action = $_SERVER['REQUEST_URI']; |
||
69 | $unique_id = uniqid(mt_rand(), true); |
||
70 | $form = '<br>'; |
||
71 | $form .= "<form name=\"form_import_{$unique_id}\" id=\"form_import_{$unique_id}\" action=\"{$currentFile}\" method=\"post\" enctype=\"multipart/form-data\">"; |
||
72 | |||
73 | $showlimit = str_replace('%s', $start + 1, _AM_XNEWSLETTER_IMPORT_SHOW); |
||
74 | if ($limitcheck < $importsCount) { |
||
75 | $showlimit = str_replace('%l', $limitcheck, $showlimit); |
||
76 | } else { |
||
77 | $showlimit = str_replace('%l', $importsCount, $showlimit); |
||
78 | } |
||
79 | $showlimit = str_replace('%n', $importsCount, $showlimit); |
||
80 | |||
81 | $form .= " |
||
82 | <table width='100%' cellspacing='1' class='outer'> |
||
83 | <tr> |
||
84 | <td align='left' colspan='8'>" . $showlimit . '</td> |
||
85 | </tr>'; |
||
86 | |||
87 | $class = 'odd'; |
||
88 | $form .= ' |
||
89 | <tr> |
||
90 | <th> </th> |
||
91 | <th>' . _AM_XNEWSLETTER_SUBSCR_EMAIL . '</th> |
||
92 | <th>' . _AM_XNEWSLETTER_SUBSCR_SEX . '</th> |
||
93 | <th>' . _AM_XNEWSLETTER_SUBSCR_FIRSTNAME . '</th> |
||
94 | <th>' . _AM_XNEWSLETTER_SUBSCR_LASTNAME . '</th> |
||
95 | <th>' . _AM_XNEWSLETTER_IMPORT_EMAIL_EXIST . '</th> |
||
96 | <th>' . _AM_XNEWSLETTER_IMPORT_CATSUBSCR_EXIST . '</th> |
||
97 | <th>' . _AM_XNEWSLETTER_CAT_NAME . '</th> |
||
98 | </tr>'; |
||
99 | |||
100 | $class = 'odd'; |
||
101 | $counter = 0; |
||
102 | |||
103 | //get data for dropdown with cats |
||
104 | $catCriteria = new \CriteriaCompo(); |
||
105 | $catCriteria->setSort('cat_id ASC, cat_name'); |
||
106 | $catCriteria->setOrder('ASC'); |
||
107 | $catObjs = $helper->getHandler('Cat')->getAll($catCriteria); |
||
108 | |||
109 | foreach ($importObjs as $i => $importObj) { |
||
110 | ++$counter; |
||
111 | $form .= "<tr class='{$class}'>"; |
||
112 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
113 | $form .= '<td>' . $counter; |
||
114 | $form .= "<input type='hidden' name='import_id_{$counter}' title='import_id_{$counter}' id='import_id_{$counter}' value='" . $importObj->getVar('import_id') . "'>"; |
||
115 | $form .= '</td>'; |
||
116 | $form .= '<td>'; |
||
117 | $form .= "<input type='text' disabled=disabled name='email_{$counter}' title='" . _AM_XNEWSLETTER_SUBSCR_EMAIL . "' id='email_{$counter}' value='" . $importObj->getVar('import_email') . "'>"; |
||
118 | $form .= '</td>'; |
||
119 | |||
120 | $form .= '<td>'; |
||
121 | $sex = $importObj->getVar('import_sex'); |
||
122 | $form .= "<select size='1' name='sex_{$counter}' id='sex_{$counter}' title='" . _AM_XNEWSLETTER_SUBSCR_SEX . "' "; |
||
123 | $form .= "value='" . $sex . "'>"; |
||
124 | $form .= "<option value=''"; |
||
125 | if (_AM_XNEWSLETTER_SUBSCR_SEX_EMPTY == $sex) { |
||
126 | $form .= ' selected'; |
||
127 | } |
||
128 | $form .= '>' . _AM_XNEWSLETTER_SUBSCR_SEX_EMPTY . '</option>'; |
||
129 | $form .= "<option value='" . _AM_XNEWSLETTER_SUBSCR_SEX_FEMALE . "'"; |
||
130 | if (_AM_XNEWSLETTER_SUBSCR_SEX_FEMALE == $sex) { |
||
131 | $form .= ' selected'; |
||
132 | } |
||
133 | $form .= '>' . _AM_XNEWSLETTER_SUBSCR_SEX_FEMALE . '</option>'; |
||
134 | $form .= "<option value='" . _AM_XNEWSLETTER_SUBSCR_SEX_MALE . "'"; |
||
135 | if (_AM_XNEWSLETTER_SUBSCR_SEX_MALE == $sex) { |
||
136 | $form .= ' selected'; |
||
137 | } |
||
138 | $form .= '>' . _AM_XNEWSLETTER_SUBSCR_SEX_MALE . '</option>'; |
||
139 | $form .= "<option value='" . _AM_XNEWSLETTER_SUBSCR_SEX_COMP . "'"; |
||
140 | if (_AM_XNEWSLETTER_SUBSCR_SEX_COMP == $sex) { |
||
141 | $form .= ' selected'; |
||
142 | } |
||
143 | $form .= '>' . _AM_XNEWSLETTER_SUBSCR_SEX_COMP . '</option>'; |
||
144 | $form .= "<option value='" . _AM_XNEWSLETTER_SUBSCR_SEX_FAMILY . "'"; |
||
145 | if (_AM_XNEWSLETTER_SUBSCR_SEX_FAMILY == $sex) { |
||
146 | $form .= ' selected'; |
||
147 | } |
||
148 | $form .= '>' . _AM_XNEWSLETTER_SUBSCR_SEX_FAMILY . '</option>'; |
||
149 | $form .= "</select>\n"; |
||
150 | $form .= '</td>'; |
||
151 | |||
152 | $form .= '<td>'; |
||
153 | $form .= "<input type='text' name='firstname_{$counter}' title='" . _AM_XNEWSLETTER_SUBSCR_FIRSTNAME . "' id='firstname_{$counter}' value='" . $importObj->getVar('import_firstname') . "'>"; |
||
154 | $form .= '</td>'; |
||
155 | $form .= '<td>'; |
||
156 | $form .= "<input type='text' name='lastname_{$counter}' title='" . _AM_XNEWSLETTER_SUBSCR_LASTNAME . "' id='lastname_{$counter}' value='" . $importObj->getVar('import_lastname') . "'>"; |
||
157 | $form .= '</td>'; |
||
158 | $form .= '<td>'; |
||
159 | $subscr_id = $importObj->getVar('import_subscr_id'); |
||
160 | $form .= "<input type='hidden' name='subscr_id_{$counter}' title='subscr_id' id='subscr_id_{$counter}' value='" . $subscr_id . "'>"; |
||
161 | if ($subscr_id > 0) { |
||
162 | $form .= "<img src='" . XNEWSLETTER_ICONS_URL . "/xn_ok.png' alt='" . _AM_XNEWSLETTER_IMPORT_EMAIL_EXIST . "' title='" . _AM_XNEWSLETTER_IMPORT_EMAIL_EXIST . "'>"; |
||
163 | } |
||
164 | $form .= '</td>'; |
||
165 | $form .= '<td>'; |
||
166 | $catsubscr_id = $importObj->getVar('import_catsubscr_id'); |
||
167 | $form .= "<input type='hidden' name='catsubscr_id_{$counter}' title='catsubscr_id' id='catsubscr_id_{$counter}' value='" . $catsubscr_id . "'>"; |
||
168 | if ($catsubscr_id > 0) { |
||
169 | $form .= "<img src='" . XNEWSLETTER_ICONS_URL . "/xn_ok.png' alt='" . _AM_XNEWSLETTER_IMPORT_CATSUBSCR_EXIST . "' title='" . _AM_XNEWSLETTER_IMPORT_CATSUBSCR_EXIST . "'>"; |
||
170 | } |
||
171 | $form .= '</td>'; |
||
172 | $form .= '</td>'; |
||
173 | $form .= '<td>'; |
||
174 | $curr_cat_id = $importObj->getVar('import_cat_id'); |
||
175 | $form .= "<select size='1' name='cat_id_{$counter}' id=\"cat_id_{$counter}' title='cat' "; |
||
176 | $form .= "value='" . $curr_cat_id . "'>"; |
||
177 | $cat_select = "<option value='0'"; |
||
178 | $cat_select .= '>' . _AM_XNEWSLETTER_IMPORT_NOIMPORT . '</option>'; |
||
179 | foreach ($catObjs as $cat_id => $catObj) { |
||
180 | $cat_select .= "<option value='" . $cat_id . "'"; |
||
181 | if ($curr_cat_id == $cat_id) { |
||
182 | $cat_select .= ' selected'; |
||
183 | } |
||
184 | $cat_select .= '>' . $catObj->getVar('cat_name') . '</option>'; |
||
185 | } |
||
186 | |||
187 | $form .= $cat_select; |
||
188 | $form .= "</select>\n"; |
||
189 | |||
190 | $form .= '</td>'; |
||
191 | $form .= '</tr>'; |
||
192 | } |
||
193 | $form .= "<tr class='{$class}'>"; |
||
194 | $class = ('even' === $class) ? 'odd' : 'even'; |
||
195 | $form .= "<td colspan='8'>"; |
||
196 | $form .= "<input type='hidden' name='counter' title='counter' id='counter' value='{$counter}'>"; |
||
197 | $form .= "<input type='hidden' name='limitcheck' title='limitcheck' id='limitcheck' value='" . $limitcheck . "'>"; |
||
198 | $form .= "<input type='hidden' name='op' title='op' id='op' value='apply_import_form'>"; |
||
199 | $form .= "<input type='submit' class='formButton' name='submit' id='submit' value='" . _AM_XNEWSLETTER_IMPORT_EXEC . "' title='" . _AM_XNEWSLETTER_IMPORT_EXEC . "'>"; |
||
200 | $form .= '</td></tr>'; |
||
201 | |||
202 | $form .= '</table></form>'; |
||
203 | $GLOBALS['xoopsTpl']->assign('form', $form); |
||
204 | } |
||
205 | break; |
||
206 | case 'apply_import_form': |
||
207 | //update xnewsletter with settings form_import |
||
208 | $counter = Request::getInt('counter', 0); |
||
209 | |||
210 | for ($i = 1; $i < ($counter + 1); ++$i) { |
||
211 | $import_id = Request::getString("import_id_{$i}", 'default'); |
||
212 | $subscr_firstname = Request::getString("firstname_{$i}", ''); |
||
213 | $subscr_lastname = Request::getString("lastname_{$i}", ''); |
||
214 | $subscr_sex = Request::getString("sex_{$i}", ''); |
||
215 | $cat_id = Request::getInt("cat_id_{$i}", 0); |
||
216 | |||
217 | if ($cat_id > 0) { |
||
218 | if (0 == $subscr_id) { |
||
219 | //update sex, firstname, lastname |
||
220 | $sql = "UPDATE {$xoopsDB->prefix('xnewsletter_import')}"; |
||
221 | $sql .= " SET `import_sex`='{$subscr_sex}', `import_firstname`='{$subscr_firstname}', `import_lastname`='{$subscr_lastname}'"; |
||
222 | $sql .= " WHERE `import_id`={$import_id}"; |
||
223 | $result = $xoopsDB->queryF($sql); |
||
224 | } |
||
225 | } |
||
226 | //update cat_id and import_status |
||
227 | $sql = "UPDATE {$xoopsDB->prefix('xnewsletter_import')}"; |
||
228 | $sql .= " SET `import_cat_id`='{$cat_id}', `import_status`=1"; |
||
229 | $sql .= " WHERE `import_id`={$import_id}"; |
||
230 | $result = $xoopsDB->queryF($sql); |
||
231 | } |
||
232 | |||
233 | redirect_header("?op=exec_import_final&check_import=1&limitcheck={$limitcheck}", 0, ''); |
||
234 | break; |
||
235 | case 'exec_import_final': |
||
236 | //execute final import of all data from xnewsletter_import, where import_status = true |
||
237 | //delete data from xnewsletter_import, when imported (successful or not) |
||
238 | $adminObject->addItemButton(_AM_XNEWSLETTER_IMPORT_PLUGINS_AVAIL, $currentFile, 'list'); |
||
239 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left')); |
||
240 | |||
241 | $ip = xoops_getenv('REMOTE_ADDR'); |
||
242 | $submitter = $xoopsUser->uid(); |
||
243 | |||
244 | $importCriteria = new \CriteriaCompo(); |
||
245 | $importCriteria->add(new \Criteria('import_status', true)); |
||
246 | $numrows_total = $helper->getHandler('Import')->getCount(); |
||
247 | $numrows_act = $helper->getHandler('Import')->getCount($importCriteria); |
||
248 | if ($numrows_act > 0) { |
||
249 | $sql = 'SELECT *'; |
||
250 | $sql .= " FROM {$xoopsDB->prefix('xnewsletter_import')}"; |
||
251 | $sql .= ' WHERE ((import_status)=1)'; |
||
252 | $sql .= ' ORDER BY `import_id` ASC'; |
||
253 | $counter = 0; |
||
254 | if (!$users_import = $xoopsDB->queryF($sql)) { |
||
255 | die('MySQL-Error: ' . $GLOBALS['xoopsDB']->error()); |
||
256 | } |
||
257 | while (null !== ($user_import = mysqli_fetch_assoc($users_import))) { |
||
258 | $import_id = $user_import['import_id']; |
||
259 | $subscr_email = $user_import['import_email']; |
||
260 | $subscr_firstname = $user_import['import_firstname']; |
||
261 | $subscr_lastname = $user_import['import_lastname']; |
||
262 | $subscr_sex = $user_import['import_sex']; |
||
263 | $cat_id = $user_import['import_cat_id']; |
||
264 | $subscr_id = $user_import['import_subscr_id']; |
||
265 | $catsubscr_id = $user_import['import_catsubscr_id']; |
||
266 | $subscribe = 0; |
||
267 | |||
268 | if (0 == $cat_id) { |
||
269 | createProtocol(str_replace('%e', $subscr_email, _AM_XNEWSLETTER_IMPORT_RESULT_SKIP), true, $submitter); |
||
270 | } else { |
||
271 | //register email |
||
272 | if (0 == $subscr_id) { |
||
273 | $subscr_uid = 0; |
||
274 | $sql = 'SELECT `uid`'; |
||
275 | $sql .= " FROM {$xoopsDB->prefix('users')}"; |
||
276 | $sql .= " WHERE (`email`='{$subscr_email}') LIMIT 1"; |
||
277 | $user = $xoopsDB->queryF($sql); |
||
278 | if ($user) { |
||
279 | $row_user = $xoopsDB->fetchBoth($user); |
||
280 | $subscr_uid = $row_user[0]; |
||
281 | } |
||
282 | unset($row_user); |
||
283 | unset($user); |
||
284 | |||
285 | $sql = 'INSERT'; |
||
286 | $sql .= " INTO `{$xoopsDB->prefix('xnewsletter_subscr')}`"; |
||
287 | $sql .= ' (`subscr_email`, `subscr_firstname`, `subscr_lastname`, `subscr_uid`, `subscr_sex`, `subscr_submitter`, `subscr_created`, `subscr_ip`, `subscr_activated`, `subscr_actoptions`)'; |
||
288 | $sql .= " VALUES ('{$subscr_email}', '{$subscr_firstname}', '{$subscr_lastname}', " . $subscr_uid . ", '{$subscr_sex}', {$submitter}, " . time() . ",'{$ip}', 1, '')"; |
||
289 | if (!$xoopsDB->queryF($sql)) { |
||
290 | createProtocol(str_replace('%e', $subscr_email, _AM_XNEWSLETTER_IMPORT_RESULT_FAILED), false, $submitter); |
||
291 | } else { |
||
292 | //register email successful |
||
293 | $resulttext = $subscr_email . ': ' . _AM_XNEWSLETTER_IMPORT_RESULT_REG_OK . ' | '; |
||
294 | $subscr_id = $xoopsDB->getInsertId(); |
||
295 | $subscribe = 1; |
||
296 | } |
||
297 | } else { |
||
298 | //email already registered |
||
299 | $resulttext = $subscr_email . ': ' . _AM_XNEWSLETTER_IMPORT_EMAIL_EXIST . ' | '; |
||
300 | $subscribe = 1; |
||
301 | } |
||
302 | if (1 == $subscribe) { |
||
303 | if (0 == $catsubscr_id) { |
||
304 | //add subscription of this email |
||
305 | $sql = 'INSERT'; |
||
306 | $sql .= " INTO `{$xoopsDB->prefix('xnewsletter_catsubscr')}`"; |
||
307 | $sql .= ' (`catsubscr_catid`, `catsubscr_subscrid`, `catsubscr_submitter`, `catsubscr_created`)'; |
||
308 | $sql .= " VALUES ({$cat_id}, {$subscr_id}, {$submitter}," . time() . ')'; |
||
309 | if ($xoopsDB->queryF($sql)) { |
||
310 | createProtocol($resulttext . _AM_XNEWSLETTER_IMPORT_RESULT_SUBSCR_OK, true, $submitter); |
||
311 | //handle mailinglists |
||
312 | $cat_mailinglist = 0; |
||
313 | $sql = 'SELECT `cat_mailinglist`'; |
||
314 | $sql .= " FROM {$xoopsDB->prefix('xnewsletter_cat')}"; |
||
315 | $sql .= " WHERE (`cat_id`={$cat_id}) LIMIT 1"; |
||
316 | $cat_mls = $xoopsDB->queryF($sql); |
||
317 | if ($cat_mls) { |
||
318 | $cat_ml = $xoopsDB->fetchBoth($cat_mls); |
||
319 | $cat_mailinglist = $cat_ml[0]; |
||
320 | } |
||
321 | unset($cat_ml); |
||
322 | unset($cat_mls); |
||
323 | |||
324 | if ($cat_mailinglist > 0) { |
||
325 | require_once XOOPS_ROOT_PATH . '/modules/xnewsletter/include/mailinglist.php'; |
||
326 | subscribingMLHandler(_XNEWSLETTER_MAILINGLIST_SUBSCRIBE, $subscr_id, $cat_mailinglist); |
||
327 | } |
||
328 | } else { |
||
329 | createProtocol(str_replace('%e', $subscr_email, _AM_XNEWSLETTER_IMPORT_RESULT_FAILED), false, $submitter); |
||
330 | } |
||
331 | } else { |
||
332 | createProtocol($resulttext . _AM_XNEWSLETTER_IMPORT_CATSUBSCR_EXIST, true, $submitter); |
||
333 | } |
||
334 | } |
||
335 | } |
||
336 | $sql_del = 'DELETE'; |
||
337 | $sql_del .= " FROM {$xoopsDB->prefix('xnewsletter_import')}"; |
||
338 | $sql_del .= " WHERE `import_id`={$import_id}"; |
||
339 | $result = $xoopsDB->queryF($sql_del); |
||
340 | } |
||
341 | |||
342 | $resulttext = str_replace('%p', $numrows_act, _AM_XNEWSLETTER_IMPORT_FINISHED); |
||
343 | $resulttext = str_replace('%t', $numrows_total, $resulttext); |
||
344 | $GLOBALS['xoopsTpl']->assign('resulttext', XNEWSLETTER_IMG_OK . $resulttext); |
||
345 | |||
346 | $numrows_pend = $helper->getHandler('Import')->getCount(); |
||
347 | if ($numrows_pend > 0) { |
||
348 | $form_continue = "<form id='form_continue' enctype='multipart/form-data' method='post' action='{$currentFile}' name='form_continue'>"; |
||
349 | $form_continue .= "<input id='submit' class='formButton' type='submit' title='" . _AM_XNEWSLETTER_IMPORT_CONTINUE . "' value='" . _AM_XNEWSLETTER_IMPORT_CONTINUE . "' name='submit'>"; |
||
350 | $form_continue .= '<input id="limitcheck" type="hidden" value="' . $limitcheck . '" name="limitcheck">'; |
||
351 | if (1 == $check_import) { |
||
352 | //show next form for check settings |
||
353 | $form_continue .= '<input id="op" type="hidden" value="show_formcheck" name="op">'; |
||
354 | } else { |
||
355 | // set import_status = 1 for next package |
||
356 | $sql_update = 'UPDATE ' . $xoopsDB->prefix('xnewsletter_import') . ' SET `import_status`=1 ORDER BY import_id LIMIT ' . $limitcheck; |
||
357 | $xoopsDB->queryF($sql_update); |
||
358 | //execute import for the next package |
||
359 | $form_continue .= '<input id="op" type="hidden" value="exec_import_final" name="op">'; |
||
360 | } |
||
361 | $form_continue .= '<input id="action_after_read" type="hidden" value="' . $action_after_read . '" name="action_after_read">'; |
||
362 | $form_continue .= '<input id="limitcheck" type="hidden" value="' . $limitcheck . '" name="limitcheck">'; |
||
363 | $form_continue .= '<input id="plugin" type="hidden" value="' . $plugin . '" name="plugin">'; |
||
364 | $form_continue .= '<input id="check_import" type="hidden" value="' . $check_import . '" name="check_import">'; |
||
365 | $form_continue .= '</form>'; |
||
366 | $GLOBALS['xoopsTpl']->assign('form', $form_continue); |
||
367 | } |
||
368 | } else { |
||
369 | $GLOBALS['xoopsTpl']->assign('error', _AM_XNEWSLETTER_IMPORT_NODATA); |
||
370 | } |
||
371 | break; |
||
372 | case 'searchdata': |
||
373 | //delete all existing data, import data into xnewsletter_import with plugin |
||
374 | //set cat_id as preselected, update information about existing registration/subscriptions |
||
375 | //if ($action_after_read==1) execute import else show form for check before executing import |
||
376 | |||
377 | $pluginFile = XNEWSLETTER_ROOT_PATH . "/plugins/{$plugin}.php"; |
||
378 | View Code Duplication | if (!file_exists($pluginFile)) { |
|
0 ignored issues
–
show
|
|||
379 | $GLOBALS['xoopsTpl']->assign('error', str_replace('%p', $plugin, _AM_XNEWSLETTER_IMPORT_ERROR_NO_PLUGIN)); |
||
380 | break; |
||
381 | } |
||
382 | require_once $pluginFile; |
||
383 | |||
384 | $function = 'xnewsletter_plugin_getdata_' . $plugin; |
||
385 | if (!function_exists($function)) { |
||
386 | $error = "Error: require_once function 'xnewsletter_plugin_getdata_{$plugin}' doesn't exist<br>"; |
||
387 | $error .= str_replace('%f', $plugin, _AM_XNEWSLETTER_IMPORT_ERROR_NO_FUNCTION); |
||
388 | $GLOBALS['xoopsTpl']->assign('error', $error); |
||
389 | break; |
||
390 | } |
||
391 | |||
392 | //delete all existing data |
||
393 | $sql = 'TRUNCATE TABLE ' . $xoopsDB->prefix('xnewsletter_import'); |
||
394 | $result = $xoopsDB->queryF($sql); |
||
395 | |||
396 | //import data into xnewsletter_import with plugin |
||
397 | if ('csv' === $plugin) { |
||
398 | $csv_file = $_FILES['csv_file']['tmp_name']; |
||
399 | $csv_header = Request::getInt('csv_header', 0); |
||
400 | $csv_delimiter = Request::getString('csv_delimiter', ','); |
||
401 | //$numData = $function($cat_id, $action_after_read, $limitcheck, $skipcatsubscrexist, $csv_file, $csv_delimiter, $csv_header); |
||
402 | $numData = call_user_func($function, $cat_id, $action_after_read, $limitcheck, $skipcatsubscrexist, $csv_file, $csv_delimiter, $csv_header); |
||
403 | } else { |
||
404 | if ('xoopsuser' === $plugin) { |
||
405 | $arr_groups = $_POST['xoopsuser_group']; |
||
406 | //$numData = $function($cat_id, $action_after_read, $limitcheck, $skipcatsubscrexist, $arr_groups); |
||
407 | $numData = call_user_func($function, $cat_id, $action_after_read, $limitcheck, $skipcatsubscrexist, $arr_groups); |
||
408 | } else { |
||
409 | //$numData = $function($cat_id, $action_after_read, $limitcheck, $skipcatsubscrexist); |
||
410 | $numData = call_user_func($function, $cat_id, $action_after_read, $limitcheck, $skipcatsubscrexist); |
||
411 | } |
||
412 | } |
||
413 | |||
414 | if ($numData > 0) { |
||
415 | if (0 == $action_after_read) { |
||
416 | //execute import without check |
||
417 | redirect_header("{$currentFile}?op=exec_import_final&action_after_read=0&limitcheck={$limitcheck}", 0, ''); |
||
418 | } else { |
||
419 | //show form for check before executing import |
||
420 | redirect_header("{$currentFile}?op=show_formcheck&action_after_read=1&plugin={$plugin}&limitcheck={$limitcheck}", 0, ''); |
||
421 | } |
||
422 | } else { |
||
423 | redirect_header($currentFile, 3, _AM_XNEWSLETTER_IMPORT_NODATA); |
||
424 | } |
||
425 | break; |
||
426 | case 'form_additional': |
||
427 | //show form for additional settings |
||
428 | $adminObject->addItemButton(_AM_XNEWSLETTER_IMPORT_PLUGINS_AVAIL, $currentFile, 'list'); |
||
429 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->renderButton('left')); |
||
430 | |||
431 | $pluginFile = XNEWSLETTER_ROOT_PATH . "/plugins/{$plugin}.php"; |
||
432 | View Code Duplication | if (!file_exists($pluginFile)) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
433 | $GLOBALS['xoopsTpl']->assign('error', str_replace('%p', $plugin, _AM_XNEWSLETTER_IMPORT_ERROR_NO_PLUGIN)); |
||
434 | break; |
||
435 | } |
||
436 | require_once $pluginFile; |
||
437 | |||
438 | $function = "xnewsletter_plugin_getform_{$plugin}"; |
||
439 | if (!function_exists($function)) { |
||
440 | $GLOBALS['xoopsTpl']->assign('error', str_replace('%f', $plugin, _AM_XNEWSLETTER_IMPORT_ERROR_NO_FUNCTION)); |
||
441 | break; |
||
442 | } |
||
443 | //$form = $function( $cat_id, $action_after_read, $limitcheck, $skipcatsubscrexist ); |
||
444 | $form = call_user_func($function, $cat_id, $action_after_read, $limitcheck, $skipcatsubscrexist); |
||
445 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
446 | break; |
||
447 | case 'default': |
||
448 | default: |
||
449 | //show basic search form |
||
450 | $importObj = $helper->getHandler('Import')->create(); |
||
451 | $form = $importObj->getSearchForm($plugin, $action_after_read, $limitcheck); |
||
452 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||
453 | break; |
||
454 | } |
||
455 | require_once __DIR__ . '/admin_footer.php'; |
||
456 | |||
457 | /** |
||
458 | * @param $prot_text |
||
459 | * @param $success |
||
460 | * @param $submitter |
||
461 | */ |
||
462 | function createProtocol($prot_text, $success, $submitter) |
||
463 | { |
||
464 | global $xoopsDB; |
||
465 | $sql = "INSERT INTO `{$xoopsDB->prefix('xnewsletter_protocol')}`"; |
||
466 | $sql .= ' (`protocol_letter_id`, `protocol_subscriber_id`, `protocol_status`, `protocol_success`, `protocol_submitter`, `protocol_created`)'; |
||
467 | $sql .= " VALUES (0,0,'{$prot_text}', {$success}, {$submitter}, " . time() . ')'; |
||
468 | if (!$xoopsDB->queryF($sql)) { |
||
469 | die('MySQL-Error: ' . $GLOBALS['xoopsDB']->error()); |
||
470 | } |
||
471 | } |
||
472 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.