Passed
Pull Request — master (#19)
by Michael
02:30
created

admin/modifications.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Module: XoopsTube
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 *
9
 * PHP version 5
10
 *
11
 * @category        Module
12
 * @package         Xoopstube
13
 * @author          XOOPS Development Team
14
 * @copyright       2001-2016 XOOPS Project (https://xoops.org)
15
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @link            https://xoops.org/
17
 * @since           1.0.6
18
 */
19
20
use Xmf\Module\Admin;
21
use Xmf\Request;
22
use XoopsModules\Xoopstube\{
23
    Tree,
24
    Utility
25
};
26
27
require_once __DIR__ . '/admin_header.php';
28
29
//global $xoopstubetree;
30
31
$op        = Request::getCmd('op', Request::getCmd('op', '', 'POST'), 'GET'); //cleanRequestVars($_REQUEST, 'op', '');
32
$requestid = Request::getInt('requestid', Request::getInt('requestid', 0, 'POST'), 'GET'); //cleanRequestVars($_REQUEST, 'requestid', 0);
33
34
switch (mb_strtolower($op)) {
35
    case 'listmodreqshow':
36
37
        xoops_cp_header();
38
        //    renderAdminMenu(_AM_XOOPSTUBE_MOD_MODREQUESTS);
39
40
        $sql       = 'SELECT modifysubmitter, requestid, lid, cid, title, vidid, submitter, publisher, vidsource, description, time, keywords, item_tag, picurl FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_mod') . ' WHERE requestid=' . $requestid;
41
        $mod_array = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
42
        unset($sql);
43
44
        $sql        = 'SELECT submitter, lid, cid, title, vidid, submitter, publisher, vidsource, description, time, keywords, item_tag, picurl FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . $mod_array['lid'];
45
        $orig_array = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
46
        unset($sql);
47
48
        $orig_user      = new \XoopsUser($orig_array['submitter']);
49
        $submittername  = Utility::getLinkedUserNameFromId($orig_array['submitter']);
50
        $submitteremail = $orig_user::getUnameFromId('email');
0 ignored issues
show
'email' of type string is incompatible with the type integer expected by parameter $userid of XoopsUser::getUnameFromId(). ( Ignorable by Annotation )

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

50
        $submitteremail = $orig_user::getUnameFromId(/** @scrutinizer ignore-type */ 'email');
Loading history...
51
52
        echo '<div><b>' . _AM_XOOPSTUBE_MOD_MODPOSTER . '</b> ' . $submittername . '</div>';
53
        $not_allowed = ['lid', 'submitter', 'requestid', 'modifysubmitter'];
54
        $sform       = new \XoopsThemeForm(_AM_XOOPSTUBE_MOD_ORIGINAL, 'storyform', 'index.php');
55
        foreach ($orig_array as $key => $content) {
56
            if (in_array($key, $not_allowed)) {
57
                continue;
58
            }
59
            $lang_def = constant('_AM_XOOPSTUBE_MOD_' . mb_strtoupper($key));
60
61
            if ('cid' === $key) {
62
                $sql     = 'SELECT title FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' WHERE cid=' . $content;
63
                $row     = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
64
                $content = $row['title'];
65
            }
66
67
            if ('vidsource' === $key) {
68
                require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/video.php';
69
                $content = xtubeReturnSource($content);
70
            }
71
            $sform->addElement(new \XoopsFormLabel($lang_def, $content));
72
        }
73
        $sform->display();
74
75
        $orig_user      = new \XoopsUser($mod_array['modifysubmitter']);
76
        $submittername  = Utility::getLinkedUserNameFromId($mod_array['modifysubmitter']);
77
        $submitteremail = $orig_user::getUnameFromId('email');
78
79
        echo '<div><b>' . _AM_XOOPSTUBE_MOD_MODIFYSUBMITTER . '</b> ' . $submittername . '</div>';
80
        $sform = new \XoopsThemeForm(_AM_XOOPSTUBE_MOD_PROPOSED, 'storyform', 'modifications.php');
81
        foreach ($mod_array as $key => $content) {
82
            if (in_array($key, $not_allowed)) {
83
                continue;
84
            }
85
            $lang_def = constant('_AM_XOOPSTUBE_MOD_' . mb_strtoupper($key));
86
87
            if ('cid' === $key) {
88
                $sql     = 'SELECT title FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' WHERE cid=' . $content;
89
                $row     = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
90
                $content = $row['title'];
91
            }
92
93
            if ('vidsource' === $key) {
94
                require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/video.php';
95
                $content = xtubeReturnSource($content);
96
            }
97
            $sform->addElement(new \XoopsFormLabel($lang_def, $content));
98
        }
99
        $buttonTray = new \XoopsFormElementTray('', '');
100
        $buttonTray->addElement(new \XoopsFormHidden('requestid', $requestid));
101
        $buttonTray->addElement(new \XoopsFormHidden('lid', $mod_array['requestid']));
102
        $hidden = new \XoopsFormHidden('op', 'changemodreq');
103
        $buttonTray->addElement($hidden);
104
        if ($mod_array) {
105
            $butt_dup = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BAPPROVE, 'submit');
106
            $butt_dup->setExtra('onclick="this.form.elements.op.value=\'changemodreq\'"');
107
            $buttonTray->addElement($butt_dup);
108
        }
109
        $butt_dupct2 = new \XoopsFormButton('', '', _AM_XOOPSTUBE_BIGNORE, 'submit');
110
        $butt_dupct2->setExtra('onclick="this.form.elements.op.value=\'ignoremodreq\'"');
111
        $buttonTray->addElement($butt_dupct2);
112
        $sform->addElement($buttonTray);
113
        $sform->display();
114
        xoops_cp_footer();
115
        break;
116
    case 'changemodreq':
117
        $sql         = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_mod') . ' WHERE requestid=' . $requestid;
118
        $video_array = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
119
120
        $lid          = $video_array['lid'];
121
        $cid          = $video_array['cid'];
122
        $title        = $video_array['title'];
123
        $publisher    = $GLOBALS['xoopsUser']->uname();
124
        $screenshot   = $video_array['screenshot'];
125
        $vidsource    = $video_array['vidsource'];
126
        $descriptionb = $video_array['description'];
127
        $submitter    = $video_array['modifysubmitter'];
128
        $keywords     = $video_array['keywords'];
129
        $vidid        = $video_array['vidid'];
130
        $item_tag     = $video_array['item_tag'];
131
        $picurl       = $video_array['picurl'];
132
        $title        = $video_array['title'];
133
        $time         = $video_array['time'];
134
        $updated      = time();
135
136
        $GLOBALS['xoopsDB']->query(
137
            'UPDATE '
138
            . $GLOBALS['xoopsDB']->prefix('xoopstube_videos')
139
            . " SET cid = $cid, title='$title', vidid='$vidid', screenshot='', publisher='$publisher', vidsource='$vidsource', description='$descriptionb', time='$time', keywords='$keywords', item_tag='$item_tag', picurl='$picurl', updated='$updated' WHERE lid = "
140
            . $lid
141
        );
142
        $sql    = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_mod') . ' WHERE requestid=' . $requestid;
143
        $result = $GLOBALS['xoopsDB']->query($sql);
144
        redirect_header('index.php', 1, _AM_XOOPSTUBE_MOD_REQUPDATED);
145
        break;
146
    case 'ignoremodreq':
147
        $sql = sprintf('DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_mod') . ' WHERE requestid=' . $requestid);
148
        $GLOBALS['xoopsDB']->query($sql);
149
        redirect_header('index.php', 1, _AM_XOOPSTUBE_MOD_REQDELETED);
150
        break;
151
    case 'main':
152
    default:
153
154
        $start            = Request::getInt('start', 0, 'GET');
155
        $xoopstubetree    = new Tree($GLOBALS['xoopsDB']->prefix('xoopstube_mod'), 'requestid', 0);
156
        $sql              = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_mod') . ' ORDER BY requestdate DESC';
157
        $result           = $GLOBALS['xoopsDB']->query($sql, $GLOBALS['xoopsModuleConfig']['admin_perpage'], $start);
158
        $totalmodrequests = $GLOBALS['xoopsDB']->getRowsNum($GLOBALS['xoopsDB']->query($sql));
159
160
        xoops_cp_header();
161
        $adminObject = Admin::getInstance();
162
        $adminObject->displayNavigation(basename(__FILE__));
163
164
        echo '<fieldset style="border: #E8E8E8 1px solid;">
165
              <legend style="display: inline; font-weight: bold; color: #0A3760;">' . _AM_XOOPSTUBE_MOD_MODREQUESTSINFO . '</legend>';
166
        echo '<div style="padding: 8px;">' . _AM_XOOPSTUBE_MOD_TOTMODREQUESTS . '<b>' . $totalmodrequests . '</b></div>';
167
        echo '</fieldset>';
168
169
        echo '<table width="100%" cellspacing="1" class="outer" style="font-size: smaller;>';
170
        echo '<tr style="text-align: center;">';
171
        echo '<th>' . _AM_XOOPSTUBE_MOD_MODID . '</th>';
172
        echo '<th style="text-align: left;">' . _AM_XOOPSTUBE_MOD_MODTITLE . '</th>';
173
        echo '<th>' . _AM_XOOPSTUBE_MOD_MODIFYSUBMIT . '</th>';
174
        echo '<th>' . _AM_XOOPSTUBE_MOD_DATE . '</th>';
175
        echo '<th>' . _AM_XOOPSTUBE_MINDEX_ACTION . '</th>';
176
        echo '</tr>';
177
        if ($totalmodrequests > 0) {
178
            while (false !== ($video_arr = $GLOBALS['xoopsDB']->fetchArray($result))) {
179
                $path        = $xoopstubetree->getNicePathFromId($video_arr['requestid'], 'title', 'modifications.php?op=listmodreqshow&requestid');
180
                $path        = str_replace('/', '', $path);
181
                $path        = str_replace(':', '', trim($path));
182
                $title       = trim($path);
183
                $submitter   = Utility::getLinkedUserNameFromId($video_arr['modifysubmitter']);
184
                $requestdate = Utility::getTimestamp(formatTimestamp($video_arr['requestdate'], $GLOBALS['xoopsModuleConfig']['dateformatadmin']));
185
186
                echo '<tr style="text-align: center;">';
187
                echo '<td class="head">' . $video_arr['requestid'] . '</td>';
188
                echo '<td class="even" style="text-align: left;">' . $title . '</td>';
189
                echo '<td class="even">' . $submitter . '</td>';
190
                echo '<td class="even">' . $requestdate . '</td>';
191
                echo '<td class="even"><a href="modifications.php?op=listmodreqshow&amp;requestid=' . $video_arr['requestid'] . '">' . $xtubeImageArray['view'] . '</a></td>';
192
                echo '</tr>';
193
            }
194
        } else {
195
            echo '<tr style="text-align: center;"><td class="head" colspan="7">' . _AM_XOOPSTUBE_MOD_NOMODREQUEST . '</td></tr>';
196
        }
197
        echo '</table>';
198
199
        require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
200
        //        $page = ( $totalmodrequests > $GLOBALS['xoopsModuleConfig']['admin_perpage'] ) ? _AM_xtube_MINDEX_PAGE : '';
201
        $pagenav = new \XoopsPageNav($totalmodrequests, $GLOBALS['xoopsModuleConfig']['admin_perpage'], $start, 'start');
202
        echo "<div style='text-align: right; padding: 8px;'>" . $pagenav->renderNav() . '</div>';
203
        require_once __DIR__ . '/admin_footer.php';
204
}
205