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 | * |
||
5 | * Module: SmartPartner |
||
6 | * Author: The SmartFactory <www.smartfactory.ca> |
||
7 | * Licence: GNU |
||
8 | */ |
||
9 | |||
10 | include_once __DIR__ . '/admin_header.php'; |
||
11 | |||
12 | global $smartPartnerFileHandler; |
||
13 | |||
14 | $op = ''; |
||
15 | if (isset($_GET['op'])) { |
||
16 | $op = $_GET['op']; |
||
17 | } |
||
18 | if (isset($_POST['op'])) { |
||
19 | $op = $_POST['op']; |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @param bool $showmenu |
||
24 | * @param int $fileid |
||
25 | * @param int $id |
||
26 | */ |
||
27 | function editfile($showmenu = false, $fileid = 0, $id = 0) |
||
28 | { |
||
29 | global $smartPartnerFileHandler, $xoopsModule; |
||
30 | |||
31 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
32 | // if there is a parameter, and the id exists, retrieve data: we're editing a file |
||
33 | if ($fileid != 0) { |
||
34 | |||
35 | // Creating the File object |
||
36 | $fileObj = new smartpartnerfile($fileid); |
||
37 | |||
38 | if ($fileObj->notLoaded()) { |
||
39 | redirect_header('javascript:history.go(-1)', 1, _AM_SPARTNER_NOFILESELECTED); |
||
40 | } |
||
41 | |||
42 | echo "<br>\n"; |
||
43 | echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 6px 0 0; '>" . _AM_SPARTNER_FILE_EDITING . '</span>'; |
||
44 | echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SPARTNER_FILE_EDITING_DSC . '</span>'; |
||
45 | smartpartner_collapsableBar('editfile', 'editfileicon', _AM_SPARTNER_FILE_INFORMATIONS); |
||
46 | } else { |
||
47 | // there's no parameter, so we're adding an item |
||
48 | $fileObj = $smartPartnerFileHandler->create(); |
||
49 | $fileObj->setVar('id', $id); |
||
50 | |||
51 | echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 6px 0 0; '>" . _AM_SPARTNER_FILE_ADDING . '</span>'; |
||
52 | echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SPARTNER_FILE_ADDING_DSC . '</span>'; |
||
53 | smartpartner_collapsableBar('addfile', 'addfileicon', _AM_SPARTNER_FILE_INFORMATIONS); |
||
54 | } |
||
55 | |||
56 | // FILES UPLOAD FORM |
||
57 | $files_form = new XoopsThemeForm(_AM_SPARTNER_UPLOAD_FILE, 'files_form', xoops_getenv('PHP_SELF')); |
||
58 | $files_form->setExtra("enctype='multipart/form-data'"); |
||
59 | |||
60 | // NAME |
||
61 | $name_text = new XoopsFormText(_AM_SPARTNER_FILE_NAME, 'name', 50, 255, $fileObj->name()); |
||
62 | $name_text->setDescription(_AM_SPARTNER_FILE_NAME_DSC); |
||
63 | $files_form->addElement($name_text, true); |
||
64 | |||
65 | // DESCRIPTION |
||
66 | $description_text = new XoopsFormTextArea(_AM_SPARTNER_FILE_DESCRIPTION, 'description', $fileObj->description()); |
||
67 | $description_text->setDescription(_AM_SPARTNER_FILE_DESCRIPTION_DSC); |
||
68 | $files_form->addElement($description_text); |
||
69 | |||
70 | // FILE TO UPLOAD |
||
71 | if ($fileid == 0) { |
||
72 | $file_box = new XoopsFormFile(_AM_SPARTNER_FILE_TO_UPLOAD, 'userfile', 0); |
||
73 | $file_box->setExtra("size ='50'"); |
||
74 | $files_form->addElement($file_box); |
||
75 | } |
||
76 | |||
77 | $status_select = new XoopsFormRadioYN(_AM_SPARTNER_FILE_STATUS, 'file_status', $fileObj->status()); |
||
78 | $status_select->setDescription(_AM_SPARTNER_FILE_STATUS_DSC); |
||
79 | $files_form->addElement($status_select); |
||
80 | |||
81 | $files_button_tray = new XoopsFormElementTray('', ''); |
||
82 | $files_hidden = new XoopsFormHidden('op', 'uploadfile'); |
||
83 | $files_button_tray->addElement($files_hidden); |
||
84 | |||
85 | if ($fileid == 0) { |
||
86 | $files_butt_create = new XoopsFormButton('', '', _AM_SPARTNER_UPLOAD, 'submit'); |
||
87 | $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'uploadfile\'"'); |
||
88 | $files_button_tray->addElement($files_butt_create); |
||
89 | |||
90 | $files_butt_another = new XoopsFormButton('', '', _AM_SPARTNER_FILE_UPLOAD_ANOTHER, 'submit'); |
||
91 | $files_butt_another->setExtra('onclick="this.form.elements.op.value=\'uploadanother\'"'); |
||
92 | $files_button_tray->addElement($files_butt_another); |
||
93 | } else { |
||
94 | $files_butt_create = new XoopsFormButton('', '', _AM_SPARTNER_MODIFY, 'submit'); |
||
95 | $files_butt_create->setExtra('onclick="this.form.elements.op.value=\'modify\'"'); |
||
96 | $files_button_tray->addElement($files_butt_create); |
||
97 | } |
||
98 | |||
99 | $files_butt_clear = new XoopsFormButton('', '', _AM_SPARTNER_CLEAR, 'reset'); |
||
100 | $files_button_tray->addElement($files_butt_clear); |
||
101 | |||
102 | $butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); |
||
103 | $butt_cancel->setExtra('onclick="history.go(-1)"'); |
||
104 | $files_button_tray->addElement($butt_cancel); |
||
105 | |||
106 | $files_form->addElement($files_button_tray); |
||
107 | |||
108 | // fileid |
||
109 | $files_form->addElement(new XoopsFormHidden('fileid', $fileid)); |
||
110 | |||
111 | // id |
||
112 | $files_form->addElement(new XoopsFormHidden('id', $id)); |
||
113 | |||
114 | $files_form->display(); |
||
115 | |||
116 | if ($fileid != 0) { |
||
117 | smartpartner_close_collapsable('editfile', 'editfileicon'); |
||
118 | } else { |
||
119 | smartpartner_close_collapsable('addfile', 'addfileicon'); |
||
120 | } |
||
121 | } |
||
122 | |||
123 | $false = false; |
||
124 | /* -- Available operations -- */ |
||
125 | switch ($op) { |
||
126 | case 'uploadfile': |
||
127 | smartpartner_upload_file(false, true, $false); |
||
128 | exit; |
||
129 | break; |
||
130 | |||
131 | case 'uploadanother': |
||
132 | smartpartner_upload_file(true, true, $false); |
||
133 | exit; |
||
134 | break; |
||
135 | |||
136 | case 'mod': |
||
137 | global $smartPartnerFileHandler; |
||
138 | $fileid = isset($_GET['fileid']) ? $_GET['fileid'] : 0; |
||
139 | $id = isset($_GET['id']) ? $_GET['id'] : 0; |
||
140 | if (($fileid == 0) && ($id == 0)) { |
||
141 | redirect_header('javascript:history.go(-1)', 3, _AM_SPARTNER_NOITEMSELECTED); |
||
142 | } |
||
143 | |||
144 | smartpartner_xoops_cp_header(); |
||
145 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
146 | |||
147 | editfile(true, $fileid, $id); |
||
148 | break; |
||
149 | |||
150 | case 'modify': |
||
151 | global $xoopsUser; |
||
152 | |||
153 | $fileid = isset($_POST['fileid']) ? (int)$_POST['fileid'] : 0; |
||
154 | |||
155 | // Creating the file object |
||
156 | if ($fileid != 0) { |
||
157 | $fileObj = new SmartpartnerFile($fileid); |
||
158 | } else { |
||
159 | $fileObj = $smartPartnerFileHandler->create(); |
||
160 | } |
||
161 | |||
162 | // Putting the values in the file object |
||
163 | $fileObj->setVar('name', $_POST['name']); |
||
164 | $fileObj->setVar('description', $_POST['description']); |
||
165 | $fileObj->setVar('status', (int)$_POST['file_status']); |
||
166 | |||
167 | // Storing the file |
||
168 | View Code Duplication | if (!$fileObj->store()) { |
|
169 | redirect_header('partner.php?op=mod&id=' . $fileObj->id(), 3, _AM_SPARTNER_FILE_EDITING_ERROR . smartpartner_formatErrors($fileObj->getErrors())); |
||
170 | exit; |
||
171 | } |
||
172 | |||
173 | redirect_header('partner.php?op=mod&id=' . $fileObj->id(), 2, _AM_SPARTNER_FILE_EDITING_SUCCESS); |
||
174 | |||
175 | exit(); |
||
176 | break; |
||
177 | |||
178 | View Code Duplication | case 'del': |
|
179 | global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET; |
||
180 | |||
181 | $module_id = $xoopsModule->getVar('mid'); |
||
182 | $gpermHandler = xoops_getHandler('groupperm'); |
||
183 | |||
184 | $fileid = isset($_POST['fileid']) ? (int)$_POST['fileid'] : 0; |
||
185 | $fileid = isset($_GET['fileid']) ? (int)$_GET['fileid'] : $fileid; |
||
186 | |||
187 | $fileObj = new SmartpartnerFile($fileid); |
||
188 | |||
189 | $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0; |
||
190 | $title = isset($_POST['title']) ? $_POST['title'] : ''; |
||
191 | |||
192 | if ($confirm) { |
||
193 | if (!$smartPartnerFileHandler->delete($fileObj)) { |
||
194 | redirect_header('partner.php', 2, _AM_SPARTNER_FILE_DELETE_ERROR); |
||
195 | exit; |
||
196 | } |
||
197 | |||
198 | redirect_header('partner.php', 2, sprintf(_AM_SPARTNER_FILEISDELETED, $fileObj->name())); |
||
199 | } else { |
||
200 | // no confirm: show deletion condition |
||
201 | $fileid = isset($_GET['fileid']) ? (int)$_GET['fileid'] : 0; |
||
202 | |||
203 | smartpartner_xoops_cp_header(); |
||
204 | xoops_confirm(array('op' => 'del', 'fileid' => $fileObj->fileid(), 'confirm' => 1, 'name' => $fileObj->name()), 'file.php', |
||
205 | _AM_SPARTNER_DELETETHISFILE . ' <br>' . $fileObj->name() . ' <br> <br>', _AM_SPARTNER_DELETE); |
||
206 | xoops_cp_footer(); |
||
207 | } |
||
208 | |||
209 | exit(); |
||
210 | break; |
||
211 | |||
212 | case 'default': |
||
213 | default: |
||
214 | smartpartner_xoops_cp_header(); |
||
215 | |||
216 | exit; |
||
217 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
218 | include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
219 | |||
220 | global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModuleConfig, $xoopsModule; |
||
221 | |||
222 | echo "<br>\n"; |
||
223 | |||
224 | smartpartner_collapsableBar('toptable', 'toptableicon', _AM_SPARTNER_PUBLISHEDITEMS, _AM_SPARTNER_PUBLISHED_DSC); |
||
225 | |||
226 | // Get the total number of published ITEM |
||
227 | $totalitems = $smartPartnerItemHandler->getItemsCount(-1, array(_SPARTNER_STATUS_PUBLISHED)); |
||
228 | |||
229 | // creating the item objects that are published |
||
230 | $itemsObj = $smartPartnerItemHandler->getAllPublished($xoopsModuleConfig['perpage'], $startitem); |
||
231 | $totalItemsOnPage = count($itemsObj); |
||
232 | |||
233 | echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>"; |
||
234 | echo '<tr>'; |
||
235 | echo "<td width='40' class='bg3' align='center'><b>" . _AM_SPARTNER_ITEMID . '</b></td>'; |
||
236 | echo "<td width='20%' class='bg3' align='left'><b>" . _AM_SPARTNER_ITEMCATEGORYNAME . '</b></td>'; |
||
237 | echo "<td class='bg3' align='left'><b>" . _AM_SPARTNER_TITLE . '</b></td>'; |
||
238 | echo "<td width='90' class='bg3' align='center'><b>" . _AM_SPARTNER_CREATED . '</b></td>'; |
||
239 | echo "<td width='60' class='bg3' align='center'><b>" . _AM_SPARTNER_ACTION . '</b></td>'; |
||
240 | echo '</tr>'; |
||
241 | if ($totalitems > 0) { |
||
242 | for ($i = 0; $i < $totalItemsOnPage; ++$i) { |
||
243 | $categoryObj =& $itemsObj[$i]->category(); |
||
244 | |||
245 | $modify = "<a href='partner.php?op=mod&id=" |
||
246 | . $itemsObj[$i]->id() |
||
247 | . "'><img src='" |
||
248 | . $pathIcon16 |
||
249 | . '/edit.png' |
||
250 | . "' title='" |
||
251 | . _AM_SPARTNER_EDITITEM |
||
252 | . "' alt='" |
||
253 | . _AM_SPARTNER_EDITITEM |
||
254 | . "' /></a>"; |
||
255 | $delete = "<a href='partner.php?op=del&id=" |
||
256 | . $itemsObj[$i]->id() |
||
257 | . "'><img src='" |
||
258 | . $pathIcon16 |
||
259 | . '/delete.png' |
||
260 | . "' title='" |
||
261 | . _AM_SPARTNER_EDITITEM |
||
262 | . "' alt='" |
||
263 | . _AM_SPARTNER_DELETEITEM |
||
264 | . "'/></a>"; |
||
265 | |||
266 | echo '<tr>'; |
||
267 | echo "<td class='head' align='center'>" . $itemsObj[$i]->id() . '</td>'; |
||
268 | echo "<td class='even' align='left'>" . $categoryObj->name() . '</td>'; |
||
269 | echo "<td class='even' align='left'><a href='" |
||
270 | . XOOPS_URL |
||
271 | . '/modules/' |
||
272 | . $xoopsModule->dirname() |
||
273 | . '/partner.php?id=' |
||
274 | . $itemsObj[$i]->id() |
||
275 | . "'>" |
||
276 | . $itemsObj[$i]->title() |
||
277 | . '</a></td>'; |
||
278 | echo "<td class='even' align='center'>" . $itemsObj[$i]->datesub() . '</td>'; |
||
279 | echo "<td class='even' align='center'> $modify $delete </td>"; |
||
280 | echo '</tr>'; |
||
281 | } |
||
282 | } else { |
||
283 | $id = -1; |
||
284 | echo '<tr>'; |
||
285 | echo "<td class='head' align='center' colspan= '7'>" . _AM_SPARTNER_NOITEMS . '</td>'; |
||
286 | echo '</tr>'; |
||
287 | } |
||
288 | echo "</table>\n"; |
||
289 | echo "<br>\n"; |
||
290 | |||
291 | $pagenav = new XoopsPageNav($totalitems, $xoopsModuleConfig['perpage'], $startitem, 'startitem'); |
||
292 | echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>'; |
||
293 | echo '</div>'; |
||
294 | |||
295 | $totalcategories = $smartPartnerCategoryHandler->getCategoriesCount(-1); |
||
296 | if ($totalcategories > 0) { |
||
297 | edititem(); |
||
298 | } |
||
299 | |||
300 | break; |
||
301 | } |
||
302 | //smart_modFooter(); |
||
0 ignored issues
–
show
|
|||
303 | //xoops_cp_footer(); |
||
304 | include_once __DIR__ . '/admin_footer.php'; |
||
305 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.