Completed
Push — master ( 8ca430...3024c9 )
by Michael
03:12
created

admin/modifications.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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-2013 The XOOPS Project
15
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @version         $Id$
17
 * @link            http://sourceforge.net/projects/xoops/
18
 * @since           1.0.6
19
 */
20
21
include_once __DIR__ . '/admin_header.php';
22
23
global $xoopstubetree, $xoopsModuleConfig;
24
25
$op        = xtubeCleanRequestVars($_REQUEST, 'op', '');
26
$requestid = xtubeCleanRequestVars($_REQUEST, 'requestid', 0);
27
28
switch (strtolower($op)) {
29
    case 'listmodreqshow':
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
30
31
        xoops_cp_header();
32
//    xtubeRenderAdminMenu(_AM_XOOPSTUBE_MOD_MODREQUESTS);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
33
34
        $sql
35
                   =
36
            'SELECT modifysubmitter, requestid, lid, cid, title, vidid, submitter, publisher, vidsource, description, time, keywords, item_tag, picurl FROM ' . $xoopsDB->prefix('xoopstube_mod')
37
            . ' WHERE requestid=' . $requestid;
38
        $mod_array = $xoopsDB->fetchArray($xoopsDB->query($sql));
39
        unset($sql);
40
41
        $sql
42
                    =
43
            'SELECT submitter, lid, cid, title, vidid, submitter, publisher, vidsource, description, time, keywords, item_tag, picurl FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE lid='
44
            . $mod_array['lid'];
45
        $orig_array = $xoopsDB->fetchArray($xoopsDB->query($sql));
46
        unset($sql);
47
48
        $orig_user      = new XoopsUser($orig_array['submitter']);
49
        $submittername  = xtubeGetLinkedUserNameFromId($orig_array['submitter']);
50
        $submitteremail = $orig_user->getUnameFromId('email');
51
52
        echo '<div><b>' . _AM_XOOPSTUBE_MOD_MODPOSTER . '</b> ' . $submittername . '</div>';
53
        $not_allowed = array('lid', 'submitter', 'requestid', 'modifysubmitter');
54
        $sform       = new XoopsThemeForm(_AM_XOOPSTUBE_MOD_ORIGINAL, 'storyform', 'index.php');
55 View Code Duplication
        foreach ($orig_array as $key => $content) {
56
            if (in_array($key, $not_allowed)) {
57
                continue;
58
            }
59
            $lang_def = constant('_AM_XOOPSTUBE_MOD_' . strtoupper($key));
60
61
            if ($key == 'cid') {
62
                $sql     = 'SELECT title FROM ' . $xoopsDB->prefix('xoopstube_cat') . ' WHERE cid=' . $content;
63
                $row     = $xoopsDB->fetchArray($xoopsDB->query($sql));
64
                $content = $row['title'];
65
            }
66
67
            if ($key == 'vidsource') {
68
                include_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  = xtubeGetLinkedUserNameFromId($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 View Code Duplication
        foreach ($mod_array as $key => $content) {
82
            if (in_array($key, $not_allowed)) {
83
                continue;
84
            }
85
            $lang_def = constant('_AM_XOOPSTUBE_MOD_' . strtoupper($key));
86
87
            if ($key == 'cid') {
88
                $sql     = 'SELECT title FROM ' . $xoopsDB->prefix('xoopstube_cat') . ' WHERE cid=' . $content;
89
                $row     = $xoopsDB->fetchArray($xoopsDB->query($sql));
90
                $content = $row['title'];
91
            }
92
93
            if ($key == 'vidsource') {
94
                include_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
        $button_tray = new XoopsFormElementTray('', '');
100
        $button_tray->addElement(new XoopsFormHidden('requestid', $requestid));
101
        $button_tray->addElement(new XoopsFormHidden('lid', $mod_array['requestid']));
102
        $hidden = new XoopsFormHidden('op', 'changemodreq');
103
        $button_tray->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
            $button_tray->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
        $button_tray->addElement($butt_dupct2);
112
        $sform->addElement($button_tray);
113
        $sform->display();
114
        xoops_cp_footer();
115
        break;
116
117
    case 'changemodreq':
118
        $sql         = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_mod') . ' WHERE requestid=' . $requestid;
119
        $video_array = $xoopsDB->fetchArray($xoopsDB->query($sql));
120
121
        $lid          = $video_array['lid'];
122
        $cid          = $video_array['cid'];
123
        $title        = $video_array['title'];
124
        $publisher    = $xoopsUser->uname();
125
        $screenshot   = $video_array['screenshot'];
126
        $vidsource    = $video_array['vidsource'];
127
        $descriptionb = $video_array['description'];
128
        $submitter    = $video_array['modifysubmitter'];
129
        $keywords     = $video_array['keywords'];
130
        $vidid        = $video_array['vidid'];
131
        $item_tag     = $video_array['item_tag'];
132
        $picurl       = $video_array['picurl'];
133
        $title        = $video_array['title'];
134
        $time         = $video_array['time'];
135
        $updated      = time();
136
137
        $xoopsDB->query(
138
            "UPDATE " . $xoopsDB->prefix('xoopstube_videos') . " 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 = "
139
            . $lid
140
        );
141
        $sql    = 'DELETE FROM ' . $xoopsDB->prefix('xoopstube_mod') . ' WHERE requestid=' . $requestid;
142
        $result = $xoopsDB->query($sql);
143
        redirect_header('index.php', 1, _AM_XOOPSTUBE_MOD_REQUPDATED);
144
        break;
145
146
    case 'ignoremodreq':
147
        $sql = sprintf('DELETE FROM ' . $xoopsDB->prefix('xoopstube_mod') . ' WHERE requestid=' . $requestid);
148
        $xoopsDB->query($sql);
149
        redirect_header('index.php', 1, _AM_XOOPSTUBE_MOD_REQDELETED);
150
        break;
151
152
    case 'main':
153
    default:
0 ignored issues
show
The default body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a default statement must start on the line immediately following the statement.

switch ($expr) {
    default:
        doSomething(); //right
        break;
}


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
154
155
        $start            = isset($_GET['start']) ? intval($_GET['start']) : 0;
156
        $xoopstubetree    = new XoopstubeTree($xoopsDB->prefix('xoopstube_mod'), 'requestid', 0);
157
        $sql              = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_mod') . ' ORDER BY requestdate DESC';
158
        $result           = $xoopsDB->query($sql, $xoopsModuleConfig['admin_perpage'], $start);
159
        $totalmodrequests = $xoopsDB->getRowsNum($xoopsDB->query($sql));
160
161
        xoops_cp_header();
162
        $aboutAdmin = new ModuleAdmin();
163
        echo $aboutAdmin->addNavigation('modifications.php');
164
165
        echo '<fieldset style="border: #E8E8E8 1px solid;">
166
              <legend style="display: inline; font-weight: bold; color: #0A3760;">' . _AM_XOOPSTUBE_MOD_MODREQUESTSINFO . '</legend>';
167
        echo '<div style="padding: 8px;">' . _AM_XOOPSTUBE_MOD_TOTMODREQUESTS . '<b>' . $totalmodrequests . '</b></div>';
168
        echo '</fieldset>';
169
170
        echo '<table width="100%" cellspacing="1" class="outer" style="font-size: smaller;>';
171
        echo '<tr style="text-align: center;">';
172
        echo '<th>' . _AM_XOOPSTUBE_MOD_MODID . '</th>';
173
        echo '<th style="text-align: left;">' . _AM_XOOPSTUBE_MOD_MODTITLE . '</th>';
174
        echo '<th>' . _AM_XOOPSTUBE_MOD_MODIFYSUBMIT . '</th>';
175
        echo '<th>' . _AM_XOOPSTUBE_MOD_DATE . '</th>';
176
        echo '<th>' . _AM_XOOPSTUBE_MINDEX_ACTION . '</th>';
177
        echo '</tr>';
178
        if ($totalmodrequests > 0) {
179
            while ($video_arr = $xoopsDB->fetchArray($result)) {
180
                $path        = $xoopstubetree->getNicePathFromId(
181
                    $video_arr['requestid'],
182
                    'title',
183
                    'modifications.php?op=listmodreqshow&requestid'
184
                );
185
                $path        = str_replace('/', '', $path);
186
                $path        = str_replace(':', '', trim($path));
187
                $title       = trim($path);
188
                $submitter   = xtubeGetLinkedUserNameFromId($video_arr['modifysubmitter']);
189
                $requestdate = xtubeGetTimestamp(
190
                    formatTimestamp($video_arr['requestdate'], $xoopsModuleConfig['dateformatadmin'])
191
                );
192
193
                echo '<tr style="text-align: center;">';
194
                echo '<td class="head">' . $video_arr['requestid'] . '</td>';
195
                echo '<td class="even" style="text-align: left;">' . $title . '</td>';
196
                echo '<td class="even">' . $submitter . '</td>';
197
                echo '<td class="even">' . $requestdate . '</td>';
198
                echo '<td class="even"><a href="modifications.php?op=listmodreqshow&amp;requestid=' . $video_arr['requestid'] . '">' . $xtubeImageArray['view'] . '</a></td>';
199
                echo '</tr>';
200
            }
201
        } else {
202
            echo '<tr style="text-align: center;"><td class="head" colspan="7">' . _AM_XOOPSTUBE_MOD_NOMODREQUEST . '</td></tr>';
203
        }
204
        echo '</table>';
205
206
        include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
207
//        $page = ( $totalmodrequests > $xoopsModuleConfig['admin_perpage'] ) ? _AM_xtube_MINDEX_PAGE : '';
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

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.

Loading history...
208
        $pagenav = new XoopsPageNav($totalmodrequests, $xoopsModuleConfig['admin_perpage'], $start, 'start');
209
        echo "<div style='text-align: right; padding: 8px;'>" . $pagenav->renderNav() . '</div>';
210
        include_once __DIR__ . '/admin_footer.php';
211
}
212