Issues (351)

Security Analysis    no vulnerabilities found

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

admin/item.php (7 issues)

1
<?php declare(strict_types=1);
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright       XOOPS Project (https://xoops.org)
14
 * @license         https://www.fsf.org/copyleft/gpl.html GNU public license
15
 * @since           1.0
16
 * @author          trabis <[email protected]>
17
 * @author          The SmartFactory <www.smartfactory.ca>
18
 */
19
20
use Xmf\Request;
21
use XoopsModules\Publisher\Constants;
22
use XoopsModules\Publisher\Helper;
23
use XoopsModules\Publisher\Item;
24
use XoopsModules\Publisher\Utility;
25
26
require_once __DIR__ . '/admin_header.php';
27
28
// all post requests should have a valid token
29
if ('POST' === Request::getMethod() && !$GLOBALS['xoopsSecurity']->check()) {
30
    redirect_header('item.php', 2, _CO_PUBLISHER_BAD_TOKEN);
31
}
32
33
$itemId = Request::getInt('itemid', Request::getInt('itemid', 0, 'POST'), 'GET');
34
$op     = ($itemId > 0 || Request::getString('editor', '', 'POST')) ? 'mod' : '';
35
//$op     = Request::getString('op', $op, 'GET');
36
37
$op = Request::getString('op', Request::getString('op', $op, 'POST'), 'GET');
38
39
$op = Request::getString('additem', '', 'POST') ? 'additem' : (Request::getString('del', '', 'POST') ? 'del' : $op);
40
41
// Where shall we start ?
42
$submittedstartitem = Request::getInt('submittedstartitem', Request::getInt('submittedstartitem', 0, 'GET'), 'POST');
43
$publishedstartitem = Request::getInt('publishedstartitem', Request::getInt('publishedstartitem', 0, 'GET'), 'POST');
44
$expiredstartitem   = Request::getInt('publishedstartitem', Request::getInt('expiredstartitem', 0, 'GET'), 'POST');
45
$offlinestartitem   = Request::getInt('offlinestartitem', Request::getInt('offlinestartitem', 0, 'GET'), 'POST');
46
$rejectedstartitem  = Request::getInt('rejectedstartitem', Request::getInt('submittedstartitem', 0, 'GET'), 'POST');
47
48
switch ($op) {
49
    case 'clone':
50
        if (0 == $itemId) {
51
            $totalcategories = $helper->getHandler('Category')
52
                                      ->getCategoriesCount(-1);
53
            if (0 == $totalcategories) {
54
                redirect_header('category.php?op=mod', 3, _AM_PUBLISHER_NEED_CATEGORY_ITEM);
55
            }
56
        }
57
        Utility::cpHeader();
58
        publisher_editItem(true, $itemId, true);
59
        break;
60
    case 'mod':
61
        if (0 == $itemId) {
62
            $totalcategories = $helper->getHandler('Category')
63
                                      ->getCategoriesCount(-1);
64
            if (0 == $totalcategories) {
65
                redirect_header('category.php?op=mod', 3, _AM_PUBLISHER_NEED_CATEGORY_ITEM);
66
            }
67
        }
68
69
        Utility::cpHeader();
70
        publisher_editItem(true, $itemId);
71
        break;
72
    case 'additem':
73
        $redirectMsg = $errorMsg = '';
74
        // Creating the item object
75
        /** @var Item $itemObj */
76
        if (0 != $itemId) {
77
            $itemObj = $helper->getHandler('Item')
78
                              ->get($itemId);
79
        } else {
80
            $itemObj = $helper->getHandler('Item')
81
                              ->create();
82
        }
83
84
        $itemObj->setVarsFromRequest();
85
86
        $oldStatus = $itemObj->status();
87
        $newStatus = Request::getInt('status', Constants::PUBLISHER_STATUS_PUBLISHED); //_PUBLISHER_STATUS_NOTSET;
88
89
        switch ($newStatus) {
90
            case Constants::PUBLISHER_STATUS_SUBMITTED:
91
                $errorMsg = _AM_PUBLISHER_ITEMNOTCREATED;
92
                if (Constants::PUBLISHER_STATUS_NOTSET == $oldStatus) {
93
                    $errorMsg = _AM_PUBLISHER_ITEMNOTUPDATED;
94
                }
95
                $redirectMsg = _AM_PUBLISHER_ITEM_RECEIVED_NEED_APPROVAL;
96
                break;
97
            case Constants::PUBLISHER_STATUS_PUBLISHED:
98
                if ((Constants::PUBLISHER_STATUS_NOTSET == $oldStatus) || (Constants::PUBLISHER_STATUS_SUBMITTED == $oldStatus)) {
99
                    $redirectMsg = _AM_PUBLISHER_SUBMITTED_APPROVE_SUCCESS;
100
                    $notifToDo   = [Constants::PUBLISHER_NOTIFY_ITEM_PUBLISHED];
101
                } else {
102
                    $redirectMsg = _AM_PUBLISHER_PUBLISHED_MOD_SUCCESS;
103
                }
104
                $errorMsg = _AM_PUBLISHER_ITEMNOTUPDATED;
105
                break;
106
            case Constants::PUBLISHER_STATUS_OFFLINE:
107
                $redirectMsg = _AM_PUBLISHER_OFFLINE_MOD_SUCCESS;
108
                if (Constants::PUBLISHER_STATUS_NOTSET == $oldStatus) {
109
                    $redirectMsg = _AM_PUBLISHER_OFFLINE_CREATED_SUCCESS;
110
                }
111
                $errorMsg = _AM_PUBLISHER_ITEMNOTUPDATED;
112
                break;
113
            case Constants::PUBLISHER_STATUS_REJECTED:
114
                $errorMsg = _AM_PUBLISHER_ITEMNOTCREATED;
115
                if (Constants::PUBLISHER_STATUS_NOTSET == $oldStatus) {
116
                    $errorMsg = _AM_PUBLISHER_ITEMNOTUPDATED;
117
                }
118
                $redirectMsg = _AM_PUBLISHER_ITEM_REJECTED;
119
                break;
120
        }
121
        $itemObj->setVar('status', $newStatus);
122
123
        // Storing the item
124
        if (!$itemObj->store()) {
125
            redirect_header('<script>javascript:history.go(-1)</script>', 3, $errorMsg . Utility::formatErrors($itemObj->getErrors()));
126
        }
127
128
        // attach file if any
129
        if (($item_upload_file = Request::getArray('item_upload_file', '', 'FILES')) && '' !== $item_upload_file['name']) {
130
            $file_upload_result = Utility::uploadFile(false, false, $itemObj);
131
            if (true !== $file_upload_result) {
132
                redirect_header('<script>javascript:history.go(-1)</script>', 3, $file_upload_result);
133
            }
134
        }
135
136
        // Send notifications
137
        if ($notifToDo) {
138
            $itemObj->sendNotifications($notifToDo);
139
        }
140
141
        redirect_header('item.php', 2, $redirectMsg);
142
143
        break;
144
    case 'del':
145
        $itemObj = $helper->getHandler('Item')
146
                          ->get($itemId);
147
        $confirm = Request::getInt('confirm', 0, 'POST');
148
149
        if ($confirm) {
150
            if (!$helper->getHandler('Item')
151
                        ->delete($itemObj)) {
152
                redirect_header('item.php', 2, _AM_PUBLISHER_ITEM_DELETE_ERROR . Utility::formatErrors($itemObj->getErrors()));
153
            }
154
            redirect_header('item.php', 2, sprintf(_AM_PUBLISHER_ITEMISDELETED, $itemObj->getTitle()));
155
        } else {
156
            xoops_cp_header();
157
            xoops_confirm(['op' => 'del', 'itemid' => $itemObj->itemid(), 'confirm' => 1, 'name' => $itemObj->getTitle()], 'item.php', _AM_PUBLISHER_DELETETHISITEM . " <br>'" . $itemObj->getTitle() . "'. <br> <br>", _AM_PUBLISHER_DELETE);
158
            xoops_cp_footer();
159
        }
160
        exit();
161
    case 'default':
162
    default:
163
        Utility::cpHeader();
164
        //publisher_adminMenu(2, _AM_PUBLISHER_ITEMS);
165
        xoops_load('XoopsPageNav');
166
167
        echo "<br>\n";
168
        echo '<form><div style="margin-bottom: 12px;">';
169
        echo "<input type='button' name='button' onclick=\"location='item.php?op=mod'\" value='" . _AM_PUBLISHER_CREATEITEM . "'>&nbsp;&nbsp;";
170
        echo '</div></form>';
171
172
        $orderBy   = 'datesub';
173
        $ascOrDesc = 'DESC';
174
175
        // Display Submited articles
176
        Utility::openCollapsableBar('submiteditemstable', 'submiteditemsicon', _AM_PUBLISHER_SUBMISSIONSMNGMT, _AM_PUBLISHER_SUBMITTED_EXP);
177
178
        // Get the total number of submitted ITEM
179
        $totalitems = $helper->getHandler('Item')
180
                             ->getItemsCount(-1, [Constants::PUBLISHER_STATUS_SUBMITTED]);
181
182
        $itemsObj = $helper->getHandler('Item')
183
                           ->getAllSubmitted($helper->getConfig('idxcat_perpage'), $submittedstartitem, -1, $orderBy, $ascOrDesc);
184
185
        $totalItemsOnPage = count($itemsObj);
186
187
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
188
        echo '<tr>';
189
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
190
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
191
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
192
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_EXPIRE . '</strong></td>';
193
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
194
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_AUTHOR . '</strong></td>';
195
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
196
        echo '</tr>';
197
        if ($totalitems > 0) {
198
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
199
                $categoryObj = $itemsObj[$i]->getCategory();
200
201
                $approve = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['moderate'] . '</a>&nbsp;';
202
                $clone   = '';
203
                $delete  = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['delete'] . '</a>';
204
                $modify  = '';
205
206
                echo '<tr>';
207
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
208
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
209
                echo "<td class='even' align='left'><a href='" . PUBLISHER_URL . '/item.php?itemid=' . $itemsObj[$i]->itemid() . "'>" . $itemsObj[$i]->getTitle() . '</a></td>';
210
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDateExpire() . '</td>';
211
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
212
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getWho() . '</td>';
213
                echo "<td class='even' align='center'> $approve $clone $modify $delete </td>";
214
                echo '</tr>';
215
            }
216
        } else {
217
            $itemId = 0;
218
            echo '<tr>';
219
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS_SUBMITTED . '</td>';
220
            echo '</tr>';
221
        }
222
        echo "</table>\n";
223
        echo "<br>\n";
224
225
        $pagenav = new \XoopsPageNav($totalitems, $helper->getConfig('idxcat_perpage'), $submittedstartitem, 'submittedstartitem');
226
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
227
228
        Utility::closeCollapsableBar('submiteditemstable', 'submiteditemsicon');
229
230
        // Display Published articles
231
        Utility::openCollapsableBar('item_publisheditemstable', 'item_publisheditemsicon', _AM_PUBLISHER_PUBLISHEDITEMS, _AM_PUBLISHER_PUBLISHED_DSC);
232
233
        // Get the total number of published ITEM
234
        $totalitems = $helper->getHandler('Item')
235
                             ->getItemsCount(-1, [Constants::PUBLISHER_STATUS_PUBLISHED]);
236
237
        $itemsObj = $helper->getHandler('Item')
238
                           ->getAllPublished($helper->getConfig('idxcat_perpage'), $publishedstartitem, -1, $orderBy, $ascOrDesc, '', true, 'none', false);
239
240
        $totalItemsOnPage = count($itemsObj);
241
242
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
243
        echo '<tr>';
244
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
245
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
246
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
247
        echo "<th width='30' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEM_VIEWS . '</strong></td>';
248
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_EXPIRE . '</strong></td>';
249
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
250
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_AUTHOR . '</strong></td>';
251
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
252
        echo '</tr>';
253
        if ($totalitems > 0) {
254
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
255
                $categoryObj = $itemsObj[$i]->getCategory();
256
257
                $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['edit'] . '</a>';
258
                $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['delete'] . '</a>';
259
                $clone  = "<a href='item.php?op=clone&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['clone'] . '</a>';
260
261
                echo '<tr>';
262
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
263
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
264
                echo "<td class='even' align='left'>" . $itemsObj[$i]->getItemLink() . '</td>';
265
                echo "<td class='even' align='center'>" . $itemsObj[$i]->counter() . '</td>';
266
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDateExpire() . '</td>';
267
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
268
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getWho() . '</td>';
269
                echo "<td class='even' align='center'> $modify $delete $clone</td>";
270
                echo '</tr>';
271
            }
272
        } else {
273
            $itemId = 0;
274
            echo '<tr>';
275
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS . '</td>';
276
            echo '</tr>';
277
        }
278
        echo "</table>\n";
279
        echo "<br>\n";
280
281
        $pagenav = new \XoopsPageNav($totalitems, $helper->getConfig('idxcat_perpage'), $publishedstartitem, 'publishedstartitem');
282
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
283
284
        Utility::closeCollapsableBar('item_publisheditemstable', 'item_publisheditemsicon');
285
286
        // Display Offline articles
287
        Utility::openCollapsableBar('offlineitemstable', 'offlineitemsicon', _AM_PUBLISHER_ITEMS . ' ' . _CO_PUBLISHER_OFFLINE, _AM_PUBLISHER_OFFLINE_EXP);
288
289
        $totalitems = $helper->getHandler('Item')
290
                             ->getItemsCount(-1, [Constants::PUBLISHER_STATUS_OFFLINE]);
291
292
        $itemsObj = $helper->getHandler('Item')
293
                           ->getAllOffline($helper->getConfig('idxcat_perpage'), $offlinestartitem, -1, $orderBy, $ascOrDesc);
294
295
        $totalItemsOnPage = count($itemsObj);
296
297
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
298
        echo '<tr>';
299
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
300
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
301
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
302
        echo "<th width='30' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEM_VIEWS . '</strong></td>';
303
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_EXPIRE . '</strong></td>';
304
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
305
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_AUTHOR . '</strong></td>';
306
307
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
308
        echo '</tr>';
309
        if ($totalitems > 0) {
310
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
311
                $categoryObj = $itemsObj[$i]->getCategory();
312
313
                $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['edit'] . '</a>';
314
                $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['delete'] . '</a>';
315
                $clone  = "<a href='item.php?op=clone&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['clone'] . '</a>';
316
317
                echo '<tr>';
318
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
319
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
320
                echo "<td class='even' align='left'>" . $itemsObj[$i]->getItemLink() . '</td>';
321
                echo "<td class='even' align='center'>" . $itemsObj[$i]->counter() . '</td>';
322
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDateExpire() . '</td>';
323
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
324
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getWho() . '</td>';
325
                echo "<td class='even' align='center'>  $modify $delete $clone</td>";
326
                echo '</tr>';
327
            }
328
        } else {
329
            $itemId = 0;
330
            echo '<tr>';
331
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS_OFFLINE . '</td>';
332
            echo '</tr>';
333
        }
334
        echo "</table>\n";
335
        echo "<br>\n";
336
337
        $pagenav = new \XoopsPageNav($totalitems, $helper->getConfig('idxcat_perpage'), $offlinestartitem, 'offlinestartitem');
338
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
339
340
        Utility::closeCollapsableBar('offlineitemstable', 'offlineitemsicon');
341
342
        // Display Rejected articles
343
        Utility::openCollapsableBar('Rejecteditemstable', 'rejecteditemsicon', _AM_PUBLISHER_REJECTED_ITEM, _AM_PUBLISHER_REJECTED_ITEM_EXP, _AM_PUBLISHER_SUBMITTED_EXP);
0 ignored issues
show
_AM_PUBLISHER_SUBMITTED_EXP of type string is incompatible with the type boolean expected by parameter $open of XoopsModules\Publisher\U...y::openCollapsableBar(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

343
        Utility::openCollapsableBar('Rejecteditemstable', 'rejecteditemsicon', _AM_PUBLISHER_REJECTED_ITEM, _AM_PUBLISHER_REJECTED_ITEM_EXP, /** @scrutinizer ignore-type */ _AM_PUBLISHER_SUBMITTED_EXP);
Loading history...
344
345
        // Get the total number of Rejected ITEM
346
        $totalitems = $helper->getHandler('Item')
347
                             ->getItemsCount(-1, [Constants::PUBLISHER_STATUS_REJECTED]);
348
        $itemsObj   = $helper->getHandler('Item')
349
                             ->getAllRejected($helper->getConfig('idxcat_perpage'), $rejectedstartitem, -1, $orderBy, $ascOrDesc);
350
351
        $totalItemsOnPage = count($itemsObj);
352
353
        echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
354
        echo '<tr>';
355
        echo "<th width='40' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . '</strong></td>';
356
        echo "<th width='20%' class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
357
        echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_TITLE . '</strong></td>';
358
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_EXPIRE . '</strong></td>';
359
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . '</strong></td>';
360
        echo "<th width='90' class='bg3' align='center'><strong>" . _AM_PUBLISHER_AUTHOR . '</strong></td>';
361
        echo "<th width='80' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
362
        echo '</tr>';
363
364
        if ($totalitems > 0) {
365
            for ($i = 0; $i < $totalItemsOnPage; ++$i) {
366
                $categoryObj = $itemsObj[$i]->getCategory();
367
368
                $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['edit'] . '</a>';
369
                $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['delete'] . '</a>';
370
                $clone  = "<a href='item.php?op=clone&itemid=" . $itemsObj[$i]->itemid() . "'>" . $icons['clone'] . '</a>';
371
372
                echo '<tr>';
373
                echo "<td class='head' align='center'>" . $itemsObj[$i]->itemid() . '</td>';
374
                echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . '</td>';
375
                echo "<td class='even' align='left'>" . $itemsObj[$i]->getItemLink() . '</td>';
376
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDateExpire() . '</td>';
377
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getDatesub() . '</td>';
378
                echo "<td class='even' align='center'>" . $itemsObj[$i]->getWho() . '</td>';
379
                echo "<td class='even' align='center'> $modify $delete $clone</td>";
380
                echo '</tr>';
381
            }
382
        } else {
383
            $itemId = 0;
384
            echo '<tr>';
385
            echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMS_REJECTED . '</td>';
386
            echo '</tr>';
387
        }
388
        echo "</table>\n";
389
        echo "<br>\n";
390
391
        $pagenav = new \XoopsPageNav($totalitems, $helper->getConfig('idxcat_perpage'), $rejectedstartitem, 'rejectedstartitem');
392
        echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
393
394
        Utility::closeCollapsableBar('Rejecteditemstable', 'rejecteditemsicon');
395
        break;
396
}
397
require_once __DIR__ . '/admin_footer.php';
398
399
/**
400
 * @param bool $showmenu
401
 * @param int  $itemId
402
 * @param bool $clone
403
 */
404
function publisher_editItem($showmenu = false, $itemId = 0, $clone = false): void
0 ignored issues
show
The parameter $showmenu is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

404
function publisher_editItem(/** @scrutinizer ignore-unused */ $showmenu = false, $itemId = 0, $clone = false): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
405
{
406
    $helper = Helper::getInstance();
407
    global $publisherCurrentPage;
408
409
    xoops_load('XoopsFormLoader');
410
411
    $formTpl = new \XoopsTpl();
412
    //publisher_submit.html
413
414
    // if there is a parameter, and the id exists, retrieve data: we're editing a item
415
416
    if (0 !== $itemId) {
417
        // Creating the ITEM object
418
        /** @var Item $itemObj */
419
        $itemObj = $helper->getHandler('Item')
420
                          ->get($itemId);
421
422
        if (null === $itemObj) {
423
            redirect_header('item.php', 1, _AM_PUBLISHER_NOITEMSELECTED);
424
        }
425
426
        if ($clone) {
427
            $itemObj->setNew();
428
            $itemObj->setVar('itemid', 0);
429
            $itemObj->setVar('status', Constants::PUBLISHER_STATUS_NOTSET);
430
            $itemObj->setVar('datesub', time());
431
        }
432
433
        switch ($itemObj->getVar('status')) {
434
            case Constants::PUBLISHER_STATUS_SUBMITTED:
435
                $breadcrumbAction1 = _CO_PUBLISHER_SUBMITTED;
0 ignored issues
show
The assignment to $breadcrumbAction1 is dead and can be removed.
Loading history...
436
                $breadcrumbAction2 = _AM_PUBLISHER_APPROVING;
0 ignored issues
show
The assignment to $breadcrumbAction2 is dead and can be removed.
Loading history...
437
                $pageTitle         = _AM_PUBLISHER_SUBMITTED_TITLE;
438
                $pageInfo          = _AM_PUBLISHER_SUBMITTED_INFO;
439
                $buttonCaption     = _AM_PUBLISHER_APPROVE;
0 ignored issues
show
The assignment to $buttonCaption is dead and can be removed.
Loading history...
440
                $newStatus         = Constants::PUBLISHER_STATUS_PUBLISHED;
0 ignored issues
show
The assignment to $newStatus is dead and can be removed.
Loading history...
441
                break;
442
            case Constants::PUBLISHER_STATUS_PUBLISHED:
443
                $breadcrumbAction1 = _CO_PUBLISHER_PUBLISHED;
444
                $breadcrumbAction2 = _AM_PUBLISHER_EDITING;
445
                $pageTitle         = _AM_PUBLISHER_PUBLISHEDEDITING;
446
                $pageInfo          = _AM_PUBLISHER_PUBLISHEDEDITING_INFO;
447
                $buttonCaption     = _AM_PUBLISHER_MODIFY;
448
                $newStatus         = Constants::PUBLISHER_STATUS_PUBLISHED;
449
                break;
450
            case Constants::PUBLISHER_STATUS_OFFLINE:
451
                $breadcrumbAction1 = _CO_PUBLISHER_OFFLINE;
452
                $breadcrumbAction2 = _AM_PUBLISHER_EDITING;
453
                $pageTitle         = _AM_PUBLISHER_OFFLINEEDITING;
454
                $pageInfo          = _AM_PUBLISHER_OFFLINEEDITING_INFO;
455
                $buttonCaption     = _AM_PUBLISHER_MODIFY;
456
                $newStatus         = Constants::PUBLISHER_STATUS_OFFLINE;
457
                break;
458
            case Constants::PUBLISHER_STATUS_REJECTED:
459
                $breadcrumbAction1 = _CO_PUBLISHER_REJECTED;
460
                $breadcrumbAction2 = _AM_PUBLISHER_REJECTED;
461
                $pageTitle         = _AM_PUBLISHER_REJECTED_EDIT;
462
                $pageInfo          = _AM_PUBLISHER_REJECTED_EDIT_INFO;
463
                $buttonCaption     = _AM_PUBLISHER_MODIFY;
464
                $newStatus         = Constants::PUBLISHER_STATUS_REJECTED;
465
                break;
466
            case Constants::PUBLISHER_STATUS_NOTSET: // Then it's a clone...
467
                $breadcrumbAction1 = _AM_PUBLISHER_ITEMS;
468
                $breadcrumbAction2 = _AM_PUBLISHER_CLONE_NEW;
469
                $buttonCaption     = _AM_PUBLISHER_CREATE;
470
                $newStatus         = Constants::PUBLISHER_STATUS_PUBLISHED;
471
                $pageTitle         = _AM_PUBLISHER_ITEM_DUPLICATING;
472
                $pageInfo          = _AM_PUBLISHER_ITEM_DUPLICATING_DSC;
473
                break;
474
            case 'default':
475
            default:
476
                $breadcrumbAction1 = _AM_PUBLISHER_ITEMS;
477
                $breadcrumbAction2 = _AM_PUBLISHER_EDITING;
478
                $pageTitle         = _AM_PUBLISHER_PUBLISHEDEDITING;
479
                $pageInfo          = _AM_PUBLISHER_PUBLISHEDEDITING_INFO;
480
                $buttonCaption     = _AM_PUBLISHER_MODIFY;
481
                $newStatus         = Constants::PUBLISHER_STATUS_PUBLISHED;
482
                break;
483
        }
484
485
        $categoryObj = $itemObj->getCategory();
0 ignored issues
show
The assignment to $categoryObj is dead and can be removed.
Loading history...
486
487
        echo "<br>\n";
488
        Utility::openCollapsableBar('edititemtable', 'edititemicon', $pageTitle, $pageInfo);
489
490
        if ($clone) {
491
            echo '<form><div style="margin-bottom: 10px;">';
492
            echo "<input type='button' name='button' onclick=\"location='item.php?op=clone&itemid=" . $itemObj->getVar('itemid') . "'\" value='" . _AM_PUBLISHER_CLONE_ITEM . "'>&nbsp;&nbsp;";
493
            echo '</div></form>';
494
        }
495
    } else {
496
        // there's no parameter, so we're adding an item
497
        /** @var Item $itemObj */
498
        $itemObj = $helper->getHandler('Item')
499
                          ->create();
500
        $itemObj->setVarsFromRequest();
501
502
        $categoryObj       = $helper->getHandler('Category')
503
                                    ->create();
504
        $breadcrumbAction1 = _AM_PUBLISHER_ITEMS;
505
        $breadcrumbAction2 = _AM_PUBLISHER_CREATINGNEW;
506
        $buttonCaption     = _AM_PUBLISHER_CREATE;
507
        $newStatus         = Constants::PUBLISHER_STATUS_PUBLISHED;
508
509
        $categoryObj->setVar('categoryid', Request::getInt('categoryid', 0, 'GET'));
510
511
        Utility::openCollapsableBar('createitemtable', 'createitemicon', _AM_PUBLISHER_ITEM_CREATING, _AM_PUBLISHER_ITEM_CREATING_DSC);
512
    }
513
514
    $sform = $itemObj->getForm(_AM_PUBLISHER_ITEMS);
515
516
    $sform->assign($formTpl);
517
    $formTpl->display('db:publisher_submit.tpl');
518
519
    Utility::closeCollapsableBar('edititemtable', 'edititemicon');
520
521
    Utility::openCollapsableBar('pagewraptable', 'pagewrapicon', _AM_PUBLISHER_PAGEWRAP, _AM_PUBLISHER_PAGEWRAPDSC);
522
523
    $dir = Utility::getUploadDir(true, 'content');
524
525
    if (!is_writable($dir)) {
526
        echo "<span style='color:#ff0000;'><h4>" . _AM_PUBLISHER_PERMERROR . '</h4></span>';
527
    }
528
529
    // Upload File
530
    echo "<form name='form_name2' id='form_name2' action='pw_upload_file.php' method='post' enctype='multipart/form-data'>";
531
    echo "<table cellspacing='1' width='100%' class='outer'>";
532
    echo "<tr><th colspan='2'>" . _AM_PUBLISHER_UPLOAD_FILE . '</th></tr>';
533
    echo "<tr valign='top' align='left'><td class='head'>" . _AM_PUBLISHER_SEARCH_PW . "</td><td class='even'><input type='file' name='fileupload' id='fileupload' size='30'></td></tr>";
534
    echo "<tr valign='top' align='left'><td class='head'><input type='hidden' name='MAX_FILE_SIZE' id='op' value='500000'></td><td class='even'><input type='submit' name='submit' value='" . _AM_PUBLISHER_UPLOAD . "'></td></tr>";
535
    echo "<input type='hidden' name='backto' value='$publisherCurrentPage'>";
536
    echo '</table>';
537
    echo '</form>';
538
539
    // Delete File
540
    $form = new \XoopsThemeForm(_CO_PUBLISHER_DELETEFILE, 'form_name', 'pw_delete_file.php');
541
542
    $pWrapSelect = new \XoopsFormSelect(Utility::getUploadDir(true, 'content'), 'address');
543
    $folder      = dir($dir);
544
    while (false !== ($file = $folder->read())) {
545
        if ('.' !== $file && '..' !== $file) {
546
            $pWrapSelect->addOption($file, $file);
547
        }
548
    }
549
    $folder->close();
550
    $form->addElement($pWrapSelect);
551
552
    $delfile = 'delfile';
553
    $form->addElement(new \XoopsFormHidden('op', $delfile));
554
    $submit = new \XoopsFormButton('', 'submit', _AM_PUBLISHER_BUTTON_DELETE, 'submit');
555
    $form->addElement($submit);
556
557
    $form->addElement(new \XoopsFormHidden('backto', $publisherCurrentPage));
558
    $form->display();
559
560
    Utility::closeCollapsableBar('pagewraptable', 'pagewrapicon');
561
}
562