Completed
Push — master ( 3024c9...954431 )
by Michael
04:21
created

admin/brokenvideo.php (5 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-2016 XOOPS Project (http://xoops.org)
15
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @link            http://xoops.org/
17
 * @since           1.0.6
18
 */
19
20
include_once __DIR__ . '/admin_header.php';
21
22
global $xtubeImageArray, $xoopsModule;
23
24
$op  = XoopsRequest::getCmd('op', XoopsRequest::getCmd('op', '', 'POST'), 'GET'); //xtubeCleanRequestVars($_REQUEST, 'op', '');
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% 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...
25
$lid = XoopsRequest::getInt('lid', XoopsRequest::getInt('lid', 0, 'POST'), 'GET'); //xtubeCleanRequestVars($_REQUEST, 'lid', 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% 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...
26
27
switch (strtolower($op)) {
28
    case 'updatenotice':
29
        $ack         = XoopsRequest::getInt('ack', 0); //xtubeCleanRequestVars($_REQUEST, 'ack', 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% 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...
30
        $con         = XoopsRequest::getInt('con', 1); //xtubeCleanRequestVars($_REQUEST, 'con', 1);
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% 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...
31
        $update_mess = '';
32
33
        if ($ack && !$con) {
34
            $acknowledged = (0 == $ack) ? 1 : 0;
35
            $sql          = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' SET acknowledged=' . $acknowledged;
36
            if (0 == $acknowledged) {
37
                $sql .= ', confirmed=0 ';
38
            }
39
            $sql .= ' WHERE lid=' . $lid;
40
            if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
41
                XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
42
43
                return false;
44
            }
45
            $update_mess = _AM_XOOPSTUBE_BROKEN_NOWACK;
46 View Code Duplication
        } elseif (!$ack && !$con) {
47
            $acknowledged = (0 == $ack) ? 1 : 0;
48
            $sql          = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' SET acknowledged=' . $acknowledged;
49
            if (0 == $acknowledged) {
50
                $sql .= ', confirmed=0 ';
51
            }
52
            $sql .= ' WHERE lid=' . $lid;
53
            if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
54
                XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
55
56
                return false;
57
            }
58
59
            $update_mess = _AM_XOOPSTUBE_BROKEN_NOWACK;
60
        }
61
62
        if ($con) {
63
            $confirmed = (0 == $con) ? 1 : 0;
64
            $sql       = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' SET confirmed=' . $confirmed;
65
            if (1 == $confirmed) {
66
                $sql .= ', acknowledged=' . $confirmed;
67
            }
68
            $sql .= ' WHERE lid=' . $lid;
69
            if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
70
                XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
71
72
                return false;
73
            }
74
            $update_mess = _AM_XOOPSTUBE_BROKEN_NOWCON;
75 View Code Duplication
        } elseif (!$con) {
76
            $confirmed = (0 == $con) ? 1 : 0;
77
            $sql       = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' SET confirmed=' . $confirmed;
78
            if (1 == $confirmed) {
79
                $sql .= ', acknowledged=' . $confirmed;
80
            }
81
            $sql .= ' WHERE lid=' . $lid;
82
            if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
83
                XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
84
85
                return false;
86
            }
87
            $update_mess = _AM_XOOPSTUBE_BROKEN_NOWCON;
88
        }
89
        redirect_header('brokenvideo.php?op=default', 1, $update_mess);
90
        break;
91
92
    case 'delbrokenvideos':
93
        $GLOBALS['xoopsDB']->queryF('DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid=' . $lid);
94
        $GLOBALS['xoopsDB']->queryF('DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . $lid);
95
        $GLOBALS['xoopsDB']->queryF('DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_votedata') . ' WHERE lid=' . $lid);
96
        redirect_header('brokenvideo.php?op=default', 1, _AM_XOOPSTUBE_BROKENFILEDELETED);
97
98
        break;
99
100
    case 'ignorebrokenvideos':
101
        $GLOBALS['xoopsDB']->queryF('DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid=' . $lid);
102
        redirect_header('brokenvideo.php?op=default', 1, _AM_XOOPSTUBE_BROKEN_FILEIGNORED);
103
        break;
104
105
    default:
106
        $result            = $GLOBALS['xoopsDB']->query('SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' ORDER BY reportid');
107
        $totalbrokenvideos = $GLOBALS['xoopsDB']->getRowsNum($result);
108
109
        xoops_cp_header();
110
        $aboutAdmin = new ModuleAdmin();
111
        echo $aboutAdmin->addNavigation(basename(__FILE__));
112
113
        echo '
114
        <fieldset style="border: #E8E8E8 1px solid;">
115
            <legend style="display: inline; font-weight: bold; color: #0A3760;">' . _AM_XOOPSTUBE_BROKEN_REPORTINFO . '</legend>
116
            <div style="padding: 8px;">' . _AM_XOOPSTUBE_BROKEN_REPORTSNO . '&nbsp;<b>' . $totalbrokenvideos . '</b><div>
117
            <div style="padding-left: 8px;">
118
           <ul>
119
                    <li>' . $xtubeImageArray['ignore'] . '&nbsp;&nbsp;' . _AM_XOOPSTUBE_BROKEN_IGNOREDESC . '</li>
120
                    <li>' . $xtubeImageArray['editimg'] . '&nbsp;&nbsp;' . _AM_XOOPSTUBE_BROKEN_EDITDESC . '</li>
121
                    <li>' . $xtubeImageArray['deleteimg'] . '&nbsp;&nbsp;' . _AM_XOOPSTUBE_BROKEN_DELETEDESC . '</li>
122
           </ul>
123
            </div>
124
        </fieldset>';
125
126
        echo '<table width="100%" border="0" cellspacing="1" cellpadding="2" class="outer" style="font-size: smaller;">';
127
        echo '<tr style="text-align: center;">';
128
        echo '<th width="3%" style="text-align: center;">' . _AM_XOOPSTUBE_BROKEN_ID . '</th>';
129
        echo '<th width="35%" style="text-align: left;">' . _AM_XOOPSTUBE_BROKEN_TITLE . '</th>';
130
        echo '<th>' . _AM_XOOPSTUBE_BROKEN_REPORTER . '</th>';
131
        echo '<th>' . _AM_XOOPSTUBE_BROKEN_FILESUBMITTER . '</th>';
132
        echo '<th>' . _AM_XOOPSTUBE_BROKEN_DATESUBMITTED . '</th>';
133
        echo '<th>' . _AM_XOOPSTUBE_BROKEN_ACKNOWLEDGED . '</th>';
134
        echo '<th>' . _AM_XOOPSTUBE_BROKEN_DCONFIRMED . '</th>';
135
        echo '<th style="text-align: center;">' . _AM_XOOPSTUBE_BROKEN_ACTION . '</th>';
136
        echo '</tr>';
137
138
        if (0 == $totalbrokenvideos) {
139
            echo '<tr style="text-align: center;"><td style="text-align: center;" class="head" colspan="8">' . _AM_XOOPSTUBE_BROKEN_NOFILEMATCH . '</td></tr>';
140
        } else {
141
            while (false !== (list($reportid, $lid, $sender, $ip, $date, $confirmed, $acknowledged) = $GLOBALS['xoopsDB']->fetchRow($result))) {
142
                $result2 = $GLOBALS['xoopsDB']->query('SELECT cid, title, vidid, submitter FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . $lid);
143
                list($cid, $videoshowname, $vidid, $submitter) = $GLOBALS['xoopsDB']->fetchRow($result2);
144
                $email      = '';
145
                $sendername = '';
146
147 View Code Duplication
                if ($sender !== 0) {
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.

Loading history...
148
                    $result3 = $GLOBALS['xoopsDB']->query('SELECT uname, email FROM ' . $GLOBALS['xoopsDB']->prefix('users') . ' WHERE uid=' . $sender);
149
                    list($sendername, $email) = $GLOBALS['xoopsDB']->fetchRow($result3);
150
                }
151
                $result4 = $GLOBALS['xoopsDB']->query('SELECT uname, email FROM ' . $GLOBALS['xoopsDB']->prefix('users') . '  WHERE uid=' . $sender);
152
                list($ownername, $owneremail) = $GLOBALS['xoopsDB']->fetchRow($result4);
153
154
                if ('' == $ownername) {
155
                    $ownername = '&nbsp;';
156
                }
157
158
                $ack_image = $acknowledged ? $xtubeImageArray['ack_yes'] : $xtubeImageArray['ack_no'];
159
                $con_image = $confirmed ? $xtubeImageArray['con_yes'] : $xtubeImageArray['con_no'];
160
161
                echo '<tr style="text-align: center;">';
162
                echo '<td class="head">' . $reportid . '</td>';
163
                echo '<td class="even" style="text-align: left;"><a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid . '&amp;lid=' . $lid
164
                     . '" target="_blank">' . $videoshowname . '</a></td>';
165
166
                if ('' == $email) {
167
                    echo '<td class="even">' . XoopsUserUtility::getUnameFromId($sender) . ' (' . $ip . ')</td>';
168
                } else {
169
                    echo '<td class="even"><a href="mailto:' . $email . '">' . XoopsUserUtility::getUnameFromId($sender) . '</a> (' . $ip . ')</td>';
170
                }
171
                if ('' == $owneremail) {
172
                    echo '<td class="even">' . $ownername . '</td>';
173
                } else {
174
                    echo '<td class="even"><a href="mailto:' . $owneremail . '">' . $ownername . '</a></td>';
175
                }
176
                echo '<td class="even" style="text-align: center;">' . XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($date, $GLOBALS['xoopsModuleConfig']['dateformatadmin'])) . '</td>';
177
                echo '<td class="even"><a href="brokenvideo.php?op=updateNotice&amp;lid=' . $lid . '&ack=' . (int)$acknowledged . '">' . $ack_image . ' </a></td>';
178
                echo '<td class="even"><a href="brokenvideo.php?op=updateNotice&amp;lid=' . $lid . '&con=' . (int)$confirmed . '">' . $con_image . '</a></td>';
179
                echo '<td class="even" style="text-align: center;" nowrap>';
180
                echo '<a href="brokenvideo.php?op=ignorebrokenvideos&amp;lid=' . $lid . '">' . $xtubeImageArray['ignore'] . '</a>&nbsp;';
181
                echo '<a href="main.php?op=edit&amp;lid=' . $lid . '">' . $xtubeImageArray['editimg'] . '</a>&nbsp;';
182
                echo '<a href="brokenvideo.php?op=delbrokenvideos&amp;lid=' . $lid . '">' . $xtubeImageArray['deleteimg'] . '</a>';
183
                echo '</td></tr>';
184
            }
185
        }
186
        echo '</table>';
187
}
188
include_once __DIR__ . '/admin_footer.php';
189