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

admin/main.php (51 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
 * @link            http://xoops.org/
16
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
17
 * @since           1.0.6
18
 */
19
20
include_once __DIR__ . '/admin_header.php';
21
global $xoopsModule;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
22
23
$mytree = new XoopstubeTree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid');
24
25
$op  = XoopsRequest::getCmd('op', XoopsRequest::getCmd('op', '', 'POST'), 'GET');
26
$lid = XoopsRequest::getInt('lid', XoopsRequest::getInt('lid', 0, 'POST'), 'GET');
27
28
/**
29
 * @param int $lid
30
 *
31
 * @return null
32
 */
33
function edit($lid = 0)
0 ignored issues
show
edit uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
34
{
35
    global $xtubemyts, $mytree, $xtubeImageArray;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
36
37
    $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . $lid;
38
    if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
39
        XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
40
41
        return false;
42
    }
43
    $video_array  = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
44
    $directory    = $GLOBALS['xoopsModuleConfig']['videoimgdir'];
45
    $lid          = $video_array['lid'] ?: 0;
46
    $cid          = $video_array['cid'] ?: 0;
47
    $title        = $video_array['title'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['title']) : '';
48
    $vidid        = $video_array['vidid'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['vidid']) : '';
49
    $picurl       = $video_array['picurl'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['picurl']) : 'http://';
50
    $publisher    = $video_array['publisher'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['publisher']) : '';
51
    $screenshot   = $video_array['screenshot'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['screenshot']) : '';
52
    $descriptionb = $video_array['description'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['description']) : '';
53
    $published    = $video_array['published'] ?: time();
54
    $expired      = $video_array['expired'] ?: 0;
55
    $updated      = $video_array['updated'] ?: 0;
56
    $offline      = $video_array['offline'] ?: 0;
57
    $vidsource    = $video_array['vidsource'] ?: 0;
58
    $ipaddress    = $video_array['ipaddress'] ?: 0;
59
    $notifypub    = $video_array['notifypub'] ?: 0;
60
    $time         = $video_array['time'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['time']) : '0:00:00';
61
    $keywords     = $video_array['keywords'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['keywords']) : '';
62
    $item_tag     = $video_array['item_tag'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['item_tag']) : '';
63
64
    include_once __DIR__ . '/admin_header.php';
65
    xoops_cp_header();
66
    //xtubeRenderAdminMenu( _AM_XOOPSTUBE_MVIDEOS );
67
68
    if ($lid) {
69
        $_vote_data = XoopstubeUtilities::xtubeGetVoteDetails($lid);
70
        $text_info  = '
71
            <table width="100%" style="font-size: 90%;">
72
             <tr>
73
              <td style="width: 25%; border-right: #E8E8E8 1px solid; vertical-align: top; padding-left: 10px;">
74
               <div><b>' . _AM_XOOPSTUBE_VIDEO_ID . ' </b>' . $lid . '</div>
75
               <div><b>' . _AM_XOOPSTUBE_MINDEX_SUBMITTED . ': </b>' . XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($video_array['date'], $GLOBALS['xoopsModuleConfig']['dateformat'])) . '</div>
76
               <div><b>' . _AM_XOOPSTUBE_MOD_MODIFYSUBMITTER . ' </b>' . XoopstubeUtilities::xtubeGetLinkedUserNameFromId($video_array['submitter']) . '</div><div><b>' . _AM_XOOPSTUBE_VIDEO_IP
77
                      . ' </b>' . $ipaddress . '</div>
78
               <div><b>' . _AM_XOOPSTUBE_VIDEO_VIEWS . ' </b>' . $video_array['hits'] . '</div>
79
              </td>
80
              <td style="width: 25%; border-right: #E8E8E8 1px solid; vertical-align: top; padding-left: 10px;">
81
               <div><b>' . _AM_XOOPSTUBE_VOTE_TOTALRATE . ': </b>' . (int)$_vote_data['rate'] . '</div>
82
               <div><b>' . _AM_XOOPSTUBE_VOTE_USERAVG . ': </b>' . (int)round($_vote_data['avg_rate'], 2) . '</div>
83
               <div><b>' . _AM_XOOPSTUBE_VOTE_MAXRATE . ': </b>' . (int)$_vote_data['min_rate'] . '</div>
84
               <div><b>' . _AM_XOOPSTUBE_VOTE_MINRATE . ': </b>' . (int)$_vote_data['max_rate'] . '</div>
85
              </td>
86
              <td style="width: 25%; border-right: #E8E8E8 1px solid; vertical-align: top; padding-left: 10px;">
87
               <div><b>' . _AM_XOOPSTUBE_VOTE_MOSTVOTEDTITLE . ': </b>' . (int)$_vote_data['max_title'] . '</div>
88
               <div><b>' . _AM_XOOPSTUBE_VOTE_LEASTVOTEDTITLE . ': </b>' . (int)$_vote_data['min_title'] . '</div>
89
               <div><b>' . _AM_XOOPSTUBE_VOTE_REGISTERED . ': </b>' . ((int)$_vote_data['rate'] - $_vote_data['null_ratinguser']) . '</div>
90
               <div><b>' . _AM_XOOPSTUBE_VOTE_NONREGISTERED . ': </b>' . (int)$_vote_data['null_ratinguser'] . '</div>
91
              </td>
92
              <td style="width: 25%; vertical-align: top; padding-left: 10px;">
93
                <div>' . xtubeGetVideoThumb($video_array['vidid'], $video_array['title'], $video_array['vidsource'], $video_array['picurl'], $video_array['screenshot']) . '</div>
94
              </td>
95
             </tr>
96
            </table>';
97
        echo '
98
            <fieldset style="border: #E8E8E8 1px solid;"><legend style="display: inline; font-weight: bold; color: #0A3760;">' . _AM_XOOPSTUBE_INFORMATION . '</legend>
99
            <div style="padding: 8px;">' . $text_info . '</div>
100
        <!--    <div style="padding: 8px;"><li>' . $xtubeImageArray['deleteimg'] . ' ' . _AM_XOOPSTUBE_VOTE_DELETEDSC . '</li></div>\n    -->
101
            </fieldset>
102
            <br>';
103
    }
104
    unset($_vote_data);
105
106
    $caption = $lid ? _AM_XOOPSTUBE_VIDEO_MODIFYFILE : _AM_XOOPSTUBE_VIDEO_CREATENEWFILE;
107
108
    $sform = new XoopsThemeForm($caption, 'storyform', xoops_getenv('PHP_SELF'));
109
    $sform->setExtra('enctype="multipart / form - data"');
110
111
    // Video title
112
    $sform->addElement(new XoopsFormText(_AM_XOOPSTUBE_VIDEO_TITLE, 'title', 70, 255, $title), true);
113
114
    // Video source
115
    $vidsource_array  = array(
116
        0   => _AM_XOOPSTUBE_YOUTUBE,
117
        1   => _AM_XOOPSTUBE_METACAFE,
118
        2   => _AM_XOOPSTUBE_IFILM,
119
        3   => _AM_XOOPSTUBE_PHOTOBUCKET,
120
        4   => _AM_XOOPSTUBE_VIDDLER,
121
        100 => _AM_XOOPSTUBE_GOOGLEVIDEO,
122
        101 => _AM_XOOPSTUBE_MYSPAVETV,
123
        102 => _AM_XOOPSTUBE_DAILYMOTION,
124
        103 => _AM_XOOPSTUBE_BLIPTV,
125
        104 => _AM_XOOPSTUBE_CLIPFISH,
126
        105 => _AM_XOOPSTUBE_LIVELEAK,
127
        106 => _AM_XOOPSTUBE_MAKTOOB,
128
        107 => _AM_XOOPSTUBE_VEOH,
129
        108 => _AM_XOOPSTUBE_VIMEO,
130
        109 => _MD_XOOPSTUBE_MEGAVIDEO,
131
        200 => _MD_XOOPSTUBE_XOOPSTUBE
132
    ); // #200 is reserved for XoopsTube's internal FLV player
133
    $vidsource_select = new XoopsFormSelect(_AM_XOOPSTUBE_VIDSOURCE, 'vidsource', $vidsource);
134
    $vidsource_select->addOptionArray($vidsource_array);
135
    $sform->addElement($vidsource_select);
136
137
    // Video code
138
    $videocode = new XoopsFormText(_AM_XOOPSTUBE_VIDEO_DLVIDID, 'vidid', 70, 512, $vidid);
139
    $videocode->setDescription('<br><span style="font-size: small;">' . _AM_XOOPSTUBE_VIDEO_DLVIDIDDSC . '</span>');
140
    $sform->addElement($videocode, true);
141
    $note = _AM_XOOPSTUBE_VIDEO_DLVIDID_NOTE;
142
    $sform->addElement(new XoopsFormLabel('', $note));
143
144
    // Picture url
145
    $picurl = new XoopsFormText(_AM_XOOPSTUBE_VIDEO_PICURL, 'picurl', 70, 255, $picurl);
146
    $picurl->setDescription('<br><span style="font-weight: normal;font-size: smaller;">' . _AM_XOOPSTUBE_VIDEO_PICURLNOTE . '</span>');
147
    $sform->addElement($picurl, false);
148
149
    // Video publisher
150
    $sform->addElement(new XoopsFormText(_AM_XOOPSTUBE_VIDEO_PUBLISHER, 'publisher', 70, 255, $publisher), true);
151
152
    // Time form
153
    $timeform = new XoopsFormText(_AM_XOOPSTUBE_TIME, 'time', 7, 7, $time);
154
    $timeform->setDescription('<span style="font-size: small;">(h:mm:ss)</span>');
155
    $sform->addElement($timeform, false);
156
157
    // Category menu
158
    ob_start();
159
    $mytree->makeMySelBox('title', 'title', $cid, 0);
160
    $sform->addElement(new XoopsFormLabel(_AM_XOOPSTUBE_VIDEO_CATEGORY, ob_get_contents()));
161
    ob_end_clean();
162
163
    // Description form
164
    //    $editor = xtube_getWysiwygForm( _AM_XOOPSTUBE_VIDEO_DESCRIPTION, 'descriptionb', $descriptionb );
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% 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...
165
    //    $sform -> addElement( $editor, false );
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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...
166
167
    $optionsTrayNote = new XoopsFormElementTray(_AM_XOOPSTUBE_VIDEO_DESCRIPTION, '<br>');
168 View Code Duplication
    if (class_exists('XoopsFormEditor')) {
169
        $options['name']   = 'descriptionb';
170
        $options['value']  = $descriptionb;
171
        $options['rows']   = 5;
172
        $options['cols']   = '100%';
173
        $options['width']  = '100%';
174
        $options['height'] = '200px';
175
        $descriptionb      = new XoopsFormEditor('', $GLOBALS['xoopsModuleConfig']['form_options'], $options, $nohtml = false, $onfailure = 'textarea');
176
        $optionsTrayNote->addElement($descriptionb);
177
    } else {
178
        $descriptionb = new XoopsFormDhtmlTextArea('', 'descriptionb', $item->getVar('descriptionb', 'e'), '100%', '100%');
0 ignored issues
show
The variable $item does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
179
        $optionsTrayNote->addElement($descriptionb);
180
    }
181
182
    $sform->addElement($optionsTrayNote, false);
183
184
    // Meta keywords form
185
    $keywords = new XoopsFormTextArea(_AM_XOOPSTUBE_KEYWORDS, 'keywords', $keywords, 7, 60, false);
186
    $keywords->setDescription("<br><br><br><br><span style='font-size: smaller;'>" . _AM_XOOPSTUBE_KEYWORDS_NOTE . '</span>');
187
    $sform->addElement($keywords);
188
189
    // Insert tags if Tag-module is installed
190
    if (XoopstubeUtilities::xtubeIsModuleTagInstalled()) {
191
        include_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php';
192
        $text_tags = new XoopsFormTag('item_tag', 70, 255, $video_array['item_tag'], 0);
193
        $sform->addElement($text_tags);
194
    } else {
195
        $sform->addElement(new XoopsFormHidden('item_tag', $video_array['item_tag']));
196
    }
197
198
    // Video Publish Date
199
    $sform->addElement(new XoopsFormDateTime(_AM_XOOPSTUBE_VIDEO_SETPUBLISHDATE, 'published', $size = 15, $published));
200
201
    if ($lid) {
202
        $sform->addElement(new XoopsFormHidden('was_published', $published));
203
        $sform->addElement(new XoopsFormHidden('was_expired', $expired));
204
    }
205
206
    // Video Expire Date
207
    $isexpired           = ($expired > time()) ? 1 : 0;
208
    $expiredates         = ($expired > time()) ? _AM_XOOPSTUBE_VIDEO_EXPIREDATESET . XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($expired,
209
                                                                                                                                           $GLOBALS['xoopsModuleConfig']['dateformat'])) : _AM_XOOPSTUBE_VIDEO_SETDATETIMEEXPIRE;
210
    $warning             = ($published > $expired && $expired > time()) ? _AM_XOOPSTUBE_VIDEO_EXPIREWARNING : '';
211
    $expiredate_checkbox = new XoopsFormCheckBox('', 'expiredateactivate', $isexpired);
212
    $expiredate_checkbox->addOption(1, $expiredates . ' <br> <br> ');
213
214
    $expiredate_tray = new XoopsFormElementTray(_AM_XOOPSTUBE_VIDEO_EXPIREDATE . $warning, '');
215
    $expiredate_tray->addElement($expiredate_checkbox);
216
    $expiredate_tray->addElement(new XoopsFormDateTime(_AM_XOOPSTUBE_VIDEO_SETEXPIREDATE . ' <br> ', 'expired', 15, $expired));
217
    $expiredate_tray->addElement(new XoopsFormRadioYN(_AM_XOOPSTUBE_VIDEO_CLEAREXPIREDATE, 'clearexpire', 0, ' ' . _YES . '', ' ' . _NO . ''));
218
    $sform->addElement($expiredate_tray);
219
220
    // Set video offline yes/no
221
    $videostatus_radio = new XoopsFormRadioYN(_AM_XOOPSTUBE_VIDEO_FILESSTATUS, 'offline', $offline, ' ' . _YES . '', ' ' . _NO . '');
222
    $sform->addElement($videostatus_radio);
223
224
    // Set video status as updated yes/no
225
    $up_dated            = (0 == $updated) ? 0 : 1;
226
    $video_updated_radio = new XoopsFormRadioYN(_AM_XOOPSTUBE_VIDEO_SETASUPDATED, 'up_dated', $up_dated, ' ' . _YES . '', ' ' . _NO . '');
227
    $sform->addElement($video_updated_radio);
228
229
    $result = $GLOBALS['xoopsDB']->query('SELECT COUNT( * ) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid = ' . $lid);
230
    list($broken_count) = $GLOBALS['xoopsDB']->fetchRow($result);
231
    if ($broken_count > 0) {
232
        $video_updated_radio = new XoopsFormRadioYN(_AM_XOOPSTUBE_VIDEO_DELEDITMESS, 'delbroken', 1, ' ' . _YES . '', ' ' . _NO . '');
0 ignored issues
show
$video_updated_radio is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
233
        $sform->addElement($editmess_radio);
234
    }
235
236
    if ($lid && $published == 0) {
237
        $approved         = ($published == 0) ? 0 : 1;
238
        $approve_checkbox = new XoopsFormCheckBox(_AM_XOOPSTUBE_VIDEO_EDITAPPROVE, 'approved', 1);
239
        $approve_checkbox->addOption(1, ' ');
240
        $sform->addElement($approve_checkbox);
241
    }
242
243
    if (!$lid) {
244
        $button_tray = new XoopsFormElementTray('', '');
245
        $button_tray->addElement(new XoopsFormHidden('status', 1));
246
        $button_tray->addElement(new XoopsFormHidden('notifypub', $notifypub));
247
        $button_tray->addElement(new XoopsFormHidden('op', 'save'));
248
        $button_tray->addElement(new XoopsFormButton('', '', _AM_XOOPSTUBE_BSAVE, 'submit'));
249
        $sform->addElement($button_tray);
250
    } else {
251
        $button_tray = new XoopsFormElementTray('', '');
252
        $button_tray->addElement(new XoopsFormHidden('lid', $lid));
253
        $button_tray->addElement(new XoopsFormHidden('status', 2));
254
        $hidden = new XoopsFormHidden('op', 'save');
255
        $button_tray->addElement($hidden);
256
257
        $butt_dup = new XoopsFormButton('', '', _AM_XOOPSTUBE_BMODIFY, 'submit');
258
        $butt_dup->setExtra('onclick="this . form . elements . op . value = \'save\'"');
259
        $button_tray->addElement($butt_dup);
260
        $butt_dupct = new XoopsFormButton('', '', _AM_XOOPSTUBE_BDELETE, 'submit');
261
        $butt_dupct->setExtra('onclick="this.form.elements.op.value=\'delete\'"');
262
        $button_tray->addElement($butt_dupct);
263
        $butt_dupct2 = new XoopsFormButton('', '', _AM_XOOPSTUBE_BCANCEL, 'submit');
264
        $butt_dupct2->setExtra('onclick="this.form.elements.op.value=\'videosConfigMenu\'"');
265
        $button_tray->addElement($butt_dupct2);
266
        $sform->addElement($button_tray);
267
    }
268
    $sform->display();
269
    unset($hidden);
270
    include_once __DIR__ . '/admin_footer.php';
271
272
    return null;
273
}
274
275
switch (strtolower($op)) {
276
    case 'edit':
277
        edit($lid);
278
        break;
279
280
    case 'save':
281
282
        $groups    = XoopsRequest::getArray('groups', array(), 'POST'); //isset($_POST['groups']) ? $_POST['groups'] : array();
0 ignored issues
show
Unused Code Comprehensibility introduced by
81% 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...
283
        $lid       = XoopsRequest::getInt('lid', 0, 'POST');// (!empty($_POST['lid'])) ? $_POST['lid'] : 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
79% 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...
284
        $cid       = XoopsRequest::getInt('cid', 0, 'POST');// (!empty($_POST['cid'])) ? $_POST['cid'] : 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
79% 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...
285
        $vidrating = XoopsRequest::getInt('vidrating', 6, 'POST');// (!empty($_POST['vidrating'])) ? $_POST['vidrating'] : 6;
0 ignored issues
show
Unused Code Comprehensibility introduced by
79% 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...
286
        $status    = XoopsRequest::getInt('status', 2, 'POST');// (!empty($_POST['status'])) ? $_POST['status'] : 2;
0 ignored issues
show
Unused Code Comprehensibility introduced by
79% 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...
287
288
        // Get data from form
289
        $vidid        = $xtubemyts->addSlashes(XoopsRequest::getString('vidid', '', 'POST'));
290
        $picurl       = ('http://' !== XoopsRequest::getString('picurl', '', 'POST')) ? $xtubemyts->addSlashes(XoopsRequest::getString('picurl', '', 'POST')) : '';
291
        $title        = $xtubemyts->addSlashes(XoopsRequest::getString('title', '', 'POST'));
292
        $descriptionb = $xtubemyts->addSlashes(XoopsRequest::getString('descriptionb', '', 'POST'));
293
        $time         = $xtubemyts->addSlashes(XoopsRequest::getString('time', '', 'POST'));
294
        $keywords     = $xtubemyts->addSlashes(XoopsRequest::getString('keywords', '', 'POST'));
295
        $item_tag     = $xtubemyts->addSlashes(XoopsRequest::getString('item_tag', '', 'POST'));
296
        $submitter    = $GLOBALS['xoopsUser']->uid();
297
        $publisher    = $xtubemyts->addSlashes(XoopsRequest::getString('publisher', '', 'POST'));
298
        $vidsource    = XoopsRequest::getInt('vidsource', 0, 'POST'); //(!empty($_POST['vidsource'])) ? $_POST['vidsource'] : 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
82% 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...
299
        $updated      = (0 == XoopsRequest::getInt('was_published', '', 'POST')) ? 0 : time();
300
301
        //PHP 5.3
302
        $published0 = XoopsRequest::getArray('published', '', 'POST');
303
        $published  = strtotime($published0['date']) + $published0['time'];
304
305
        //          PHP 5.4
306
        //        $published    = strtotime(XoopsRequest::getArray('published', '', 'POST')['date']) + XoopsRequest::getArray('published', '', 'POST')['time'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% 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...
307
308
        if (0 == XoopsRequest::getInt('up_dated', 0, 'POST')) {
309
            $updated = 0;
310
            $status  = 1;
311
        }
312
313
        $offline   = (1 == XoopsRequest::getInt('offline', '', 'POST')) ? 1 : 0; // $_POST['offline'] == 1) ? 1 : 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
314
        $approved  = (1 == XoopsRequest::getInt('approved', '', 'POST')) ? 1 : 0; //isset($_POST['approved']) && $_POST['approved'] == 1) ? 1 : 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
68% 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...
315
        $notifypub = (1 == XoopsRequest::getInt('notifypub', '', 'POST')); //(isset($_POST['notifypub']) && $_POST['notifypub'] == 1);
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% 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...
316
317
        if (!$lid) {
318
            $date        = time();
319
            $publishdate = time();
320
            $expiredate  = '0';
321
        } else {
322
            $publishdate = XoopsRequest::getBool('was_published', false, 'POST');//$_POST['was_published'];
323
            $expiredate  = XoopsRequest::getBool('was_expired', false, 'POST');//$_POST['was_expired'];
324
        }
325
        if (1 == $approved && empty($publishdate)) {
326
            $publishdate = time();
327
        }
328
        $expiredateactivated = XoopsRequest::getInt('expiredateactivate', null, 'POST');
329
        //PHP 5.3
330
        $expiredate0 = XoopsRequest::getArray('expired', array(), 'POST');
331
        $expiredate  = strtotime($expiredate0['date']) + $expiredate0['time'];
332
        //PHP 5.4
333
        //        $expiredate = strtotime(XoopsRequest::getArray('expired', array(), 'POST')['date']) + XoopsRequest::getArray('expired', array(), 'POST')['time'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% 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...
334
        //        }
335
336
        if (!$expiredateactivated) $expiredate = '0';
337
        if (1 == XoopsRequest::getInt('clearexpire', 0, 'POST')) {
338
            $expiredate = '0';
339
        }
340
341
        // Update or insert linkload data into database
342
        if (!$lid) {
343
            $date        = time();
344
            $publishdate = time();
345
            $ipaddress   = $_SERVER['REMOTE_ADDR'];
346
            $sql         = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos')
347
                           . ' (lid, cid, title, vidid, screenshot, submitter, publisher, status, date, hits, rating, votes, comments, vidsource, published, expired, updated, offline, description, ipaddress, notifypub, vidrating, time, keywords, item_tag, picurl )';
348
            $sql .= " VALUES    (NULL, $cid, '$title', '$vidid', '', '$submitter', '$publisher', '$status', '$date', 0, 0, 0, 0, '$vidsource', '$published', '$expiredate', '$updated', '$offline', '$descriptionb', '$ipaddress', '0', '$vidrating', '$time', '$keywords', '$item_tag', '$picurl')";
349
            //    $newid = $GLOBALS['xoopsDB'] -> getInsertId();
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% 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...
350
        } else {
351
            $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos')
352
                   . " SET cid = $cid, title='$title', vidid='$vidid', screenshot='', publisher='$publisher', status='$status', vidsource='$vidsource', published='$published', expired='$expiredate', updated='$updated', offline='$offline', description='$descriptionb', vidrating='$vidrating', time='$time', keywords='$keywords', item_tag='$item_tag', picurl='$picurl' WHERE lid="
353
                   . $lid;
354
        }
355
356
        if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
357
            XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
358
359
            return false;
360
        }
361
362
        $newid = $GLOBALS['xoopsDB']->getInsertId();
363
364
        // Add item_tag to Tag-module
365 View Code Duplication
        if (!$lid) {
366
            $tagupdate = XoopstubeUtilities::xtubeUpdateTag($newid, $item_tag);
0 ignored issues
show
Are you sure the assignment to $tagupdate is correct as \XoopstubeUtilities::xtu...eTag($newid, $item_tag) (which targets XoopstubeUtilities::xtubeUpdateTag()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
367
        } else {
368
            $tagupdate = XoopstubeUtilities::xtubeUpdateTag($lid, $item_tag);
0 ignored issues
show
Are you sure the assignment to $tagupdate is correct as \XoopstubeUtilities::xtu...ateTag($lid, $item_tag) (which targets XoopstubeUtilities::xtubeUpdateTag()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
369
        }
370
371
        // Send notifications
372
        if (!$lid) {
373
            $tags                  = array();
374
            $tags['VIDEO_NAME']    = $title;
375
            $tags['VIDEO_URL']     = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid . '&amp;lid=' . $newid;
376
            $sql                   = 'SELECT title FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' WHERE cid=' . $cid;
377
            $result                = $GLOBALS['xoopsDB']->query($sql);
378
            $row                   = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
379
            $tags['CATEGORY_NAME'] = $row['title'];
380
            $tags['CATEGORY_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid;
381
            $notificationHandler   = xoops_getHandler('notification');
382
            $notificationHandler->triggerEvent('global', 0, 'new_video', $tags);
383
            $notificationHandler->triggerEvent('category', $cid, 'new_video', $tags);
384
        }
385
        if ($lid && $approved && $notifypub) {
386
            $tags                  = array();
387
            $tags['VIDEO_NAME']    = $title;
388
            $tags['VIDEO_URL']     = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid . '&amp;lid=' . $lid;
389
            $sql                   = 'SELECT title FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' WHERE cid=' . $cid;
390
            $result                = $GLOBALS['xoopsDB']->query($sql);
391
            $row                   = $GLOBALS['xoopsDB']->fetchArray($result);
392
            $tags['CATEGORY_NAME'] = $row['title'];
393
            $tags['CATEGORY_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid;
394
            $notificationHandler   = xoops_getHandler('notification');
395
            $notificationHandler->triggerEvent('global', 0, 'new_video', $tags);
396
            $notificationHandler->triggerEvent('category', $cid, 'new_video', $tags);
397
            $notificationHandler->triggerEvent('video', $lid, 'approve', $tags);
398
        }
399
        $message = (!$lid) ? _AM_XOOPSTUBE_VIDEO_NEWFILEUPLOAD : _AM_XOOPSTUBE_VIDEO_FILEMODIFIEDUPDATE;
400
        $message = ($lid && !XoopsRequest::getBool('was_published', false, 'POST') && $approved) ? _AM_XOOPSTUBE_VIDEO_FILEAPPROVED : $message;
401
402
        if (XoopsRequest::getInt('delbroken', 0)) { //xtubeCleanRequestVars($_REQUEST, 'delbroken', 0)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% 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...
403
            $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid=' . $lid;
404
            if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
405
                XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
406
407
                return false;
408
            }
409
        }
410
411
        redirect_header('main.php', 1, $message);
412
413
        break;
414
415
    case 'delete':
416
        if (XoopsRequest::getInt('confirm', 0)) { // (xtubeCleanRequestVars($_REQUEST, 'confirm', 0)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
417
            $title = XoopsRequest::getString('title', 0); //xtubeCleanRequestVars($_REQUEST, 'title', 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...
418
419
            // delete video
420
            $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . $lid;
421
            if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
422
                XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
423
424
                return false;
425
            }
426
427
            // delete altcat
428
            $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_altcat') . ' WHERE lid=' . $lid;
429
            if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
430
                XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
431
432
                return false;
433
            }
434
435
            // delete vote data
436
            $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_votedata') . ' WHERE lid=' . $lid;
437
            if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
438
                XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
439
440
                return false;
441
            }
442
443
            // delete comments
444
            xoops_comment_delete($xoopsModule->getVar('mid'), $lid);
445
            redirect_header('main.php', 1, sprintf(_AM_XOOPSTUBE_VIDEO_FILEWASDELETED, $title));
446
        } else {
447
            $sql = 'SELECT lid, title, item_tag, vidid FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . $lid;
448
            if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
449
                XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
450
451
                return false;
452
            }
453
            list($lid, $title) = $GLOBALS['xoopsDB']->fetchrow($result);
454
            $item_tag = $result['item_tag'];
455
456
            xoops_cp_header();
457
            //xtubeRenderAdminMenu( _AM_XOOPSTUBE_BINDEX );
458
459
            xoops_confirm(array(
460
                              'op'      => 'delete',
461
                              'lid'     => $lid,
462
                              'confirm' => 1,
463
                              'title'   => $title
464
                          ), 'main.php', _AM_XOOPSTUBE_VIDEO_REALLYDELETEDTHIS . '<br><br>' . $title, _DELETE);
465
466
            // Remove item_tag from Tag-module
467
            $tagupdate = XoopstubeUtilities::xtubeUpdateTag($lid, $item_tag);
0 ignored issues
show
Are you sure the assignment to $tagupdate is correct as \XoopstubeUtilities::xtu...ateTag($lid, $item_tag) (which targets XoopstubeUtilities::xtubeUpdateTag()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
468
469
            include_once __DIR__ . '/admin_footer.php';
470
        }
471
        break;
472
473
    case 'toggle':
474
        if (XoopsRequest::getInt('lid', 0, 'GET') > 0) {
475
            $a = (null === XoopsRequest::getInt('offline', null, 'GET'));
476
            $b = null === XoopsRequest::getInt('offzzline', null, 'GET');
477
            $c = null === XoopsRequest::getInt('offline', '', 'GET');
478
            $d = null === XoopsRequest::getInt('offzzline', '', 'GET');
479
            //            $e = empty(XoopsRequest::getInt('offline', 0, 'GET'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% 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...
480
            $yy  = XoopsRequest::getInt('offzzline', null, 'GET');
481
            $f0  = isset($yy);
482
            $g0  = empty($yy);
483
            $h0  = null === $yy;
484
            $yy1 = XoopsRequest::getString('offzzline');
485
            $f1  = isset($yy1);
486
            $g1  = empty($yy1);
487
            $h1  = null === $yy1;
488
489
            $yy2 = XoopsRequest::getVar('offzzline', null, 'GET');
490
            $f2  = isset($yy2);
491
            $g2  = empty($yy2);
492
            $h2  = null === $yy2;
493
494
            $xx = XoopsRequest::getInt('offline', '', 'GET');
495
            $f  = isset($xx);
496
            $g  = empty($xx);
497
            $h  = null === $xx;
498
            //            $e = empty(XoopsRequest::getInt('offline', '', 'GET'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% 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...
499
            $offline = XoopsRequest::getInt('offline', null, 'GET');
500
            if (null !== $offline) {
501
                xtubeToggleOffline($lid, $offline);
502
            }
503
        }
504
        break;
505
506
    case 'delvote':
507
        $rid = XoopsRequest::getInt('rid', 0); //xtubeCleanRequestVars($_REQUEST, 'rid', 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...
508
        $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_votedata') . ' WHERE ratingid=' . $rid;
509
        if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
510
            XoopsErrorHandler_HandleError(E_USER_WARNING, $sql, __FILE__, __LINE__);
511
512
            return false;
513
        }
514
        XoopstubeUtilities::xtubeUpdateRating($rid);
515
        redirect_header('main.php', 1, _AM_XOOPSTUBE_VOTE_VOTEDELETED);
516
        break;
517
518
    case 'main':
519
    default:
520
        $start     = XoopsRequest::getInt('start', 0, 'POST');// xtubeCleanRequestVars($_REQUEST, 'start', 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
521
        $start1    = XoopsRequest::getInt('start1', 0, 'POST');// xtubeCleanRequestVars($_REQUEST, 'start1', 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
522
        $start2    = XoopsRequest::getInt('start2', 0, 'POST');// xtubeCleanRequestVars($_REQUEST, 'start2', 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
523
        $start3    = XoopsRequest::getInt('start3', 0, 'POST');// xtubeCleanRequestVars($_REQUEST, 'start3', 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
524
        $start4    = XoopsRequest::getInt('start4', 0, 'POST');// xtubeCleanRequestVars($_REQUEST, 'start4', 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
525
        $start5    = XoopsRequest::getInt('start5', 0, 'POST');// xtubeCleanRequestVars($_REQUEST, 'start5', 0);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
526
        $totalcats = XoopstubeUtilities::xtubeGetTotalCategoryCount();
527
528
        $result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken'));
529
        list($totalbrokenvideos) = $GLOBALS['xoopsDB']->fetchRow($result);
530
        $result2 = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_mod'));
531
        list($totalmodrequests) = $GLOBALS['xoopsDB']->fetchRow($result2);
532
        $result3 = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published = 0');
533
        list($totalnewvideos) = $GLOBALS['xoopsDB']->fetchRow($result3);
534
        $result4 = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published > 0');
535
        list($totalvideos) = $GLOBALS['xoopsDB']->fetchRow($result4);
536
537
        xoops_cp_header();
538
539
        $indexAdmin = new ModuleAdmin();
540
        echo $indexAdmin->addNavigation(basename(__FILE__));
541
        $indexAdmin->addItemButton(_MI_XOOPSTUBE_ADD_VIDEO, 'main.php?op=edit', 'add', '');
542
        $indexAdmin->addItemButton(_MI_XOOPSTUBE_ADD_CATEGORY, 'category.php', 'add', '');
543
        echo $indexAdmin->renderButton('left', '');
544
545
        //xtubeRenderAdminMenu( _AM_XOOPSTUBE_BINDEX );
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
546
        //    echo '
547
        //          <fieldset style="border: #E8E8E8 1px solid;">
548
        //          <legend style="display: inline; font-weight: bold; color: #0A3760;">' . _AM_XOOPSTUBE_MINDEX_VIDEOSUMMARY . '</legend>
549
        //          <div style="padding: 8px;">
550
        //          <span style="font-size: small;">
551
        //          <a href="category.php">' . _AM_XOOPSTUBE_SCATEGORY . '</a><b>' . $totalcats . '</b> |
552
        //          <a href="main.php">' . _AM_XOOPSTUBE_SFILES . '</a><b>' . $totalvideos . '</b> |
553
        //          <a href="newvideos.php">' . _AM_XOOPSTUBE_SNEWFILESVAL . '</a><b>' . $totalnewvideos . '</b> |
554
        //          <a href="modifications.php">' . _AM_XOOPSTUBE_SMODREQUEST . '</a><b>' . $totalmodrequests . '</b> |
555
        //          <a href="brokenvideo.php">' . _AM_XOOPSTUBE_SBROKENSUBMIT . '</a><b>' . $totalbrokenvideos . '</b>
556
        //          </span>
557
        //          </div>
558
        //          </fieldset>';
559
560
        if ($totalcats > 0) {
561
            $sform = new XoopsThemeForm(_AM_XOOPSTUBE_CCATEGORY_MODIFY, 'category', 'category.php');
562
            ob_start();
563
            $mytree->makeMySelBox('title', 'title');
564
            $sform->addElement(new XoopsFormLabel(_AM_XOOPSTUBE_CCATEGORY_MODIFY_TITLE, ob_get_contents()));
565
            ob_end_clean();
566
            $dup_tray = new XoopsFormElementTray('', '');
567
            $dup_tray->addElement(new XoopsFormHidden('op', 'modCat'));
568
            $butt_dup = new XoopsFormButton('', '', _AM_XOOPSTUBE_BMODIFY, 'submit');
569
            $butt_dup->setExtra('onclick="this.form.elements.op.value=\'modCat\'"');
570
            $dup_tray->addElement($butt_dup);
571
            $butt_dupct = new XoopsFormButton('', '', _AM_XOOPSTUBE_BDELETE, 'submit');
572
            $butt_dupct->setExtra('onclick="this.form.elements.op.value=\'del\'"');
573
            $dup_tray->addElement($butt_dupct);
574
            $sform->addElement($dup_tray);
575
            $sform->display();
576
577
            //TODO add table with categories
578
579
            //            $sql='SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' ORDER BY cid DESC';
580
            //            $publishedArray       = $GLOBALS['xoopsDB']->query($sql, $GLOBALS['xoopsModuleConfig']['admin_perpage'], $start);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% 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...
581
            //            $publishedArrayCount = $GLOBALS['xoopsDB']->getRowsNum($GLOBALS['xoopsDB']->query($sql));
0 ignored issues
show
Unused Code Comprehensibility introduced by
74% 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...
582
            //            xtubeRenderCategoryListHeader(_AM_XOOPSTUBE_MINDEX_PUBLISHEDVIDEO);
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...
583
            //            xtubeSetPageNavigationCategoryList($publishedArrayCount, $start, 'art', '', 'left');
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
584
            //            if ($publishedArrayCount > 0) {
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...
585
            //                while ($published = $GLOBALS['xoopsDB']->fetchArray($publishedArray)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% 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...
586
            //                    xtubeRenderCategoryListBody($published);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
587
            //                }
588
            //                echo '</table>';
589
            //            } else {
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...
590
            //                xtubeRenderCategoryListFooter();
591
            //            }
592
            //            xtubeSetPageNavigationCategoryList($publishedArrayCount, $start, 'art', '', 'right');
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
593
        }
594
595
        if ($totalvideos > 0) {
596
            $sql                 = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published > 0  ORDER BY lid DESC';
597
            $publishedArray      = $GLOBALS['xoopsDB']->query($sql, $GLOBALS['xoopsModuleConfig']['admin_perpage'], $start);
598
            $publishedArrayCount = $GLOBALS['xoopsDB']->getRowsNum($GLOBALS['xoopsDB']->query($sql));
599
            XoopstubeUtilities::xtubeRenderVideoListHeader(_AM_XOOPSTUBE_MINDEX_PUBLISHEDVIDEO);
600
            XoopstubeUtilities::xtubeSetPageNavigationVideoList($publishedArrayCount, $start, 'art', '', 'left');
601
            if ($publishedArrayCount > 0) {
602
                while (false !== ($published = $GLOBALS['xoopsDB']->fetchArray($publishedArray))) {
603
                    XoopstubeUtilities::xtubeRenderVideoListBody($published);
604
                }
605
                echo '</table>';
606
            } else {
607
                XoopstubeUtilities::xtubeRenderVideoListFooter();
608
            }
609
            XoopstubeUtilities::xtubeSetPageNavigationVideoList($publishedArrayCount, $start, 'art', '', 'right');
610
        }
611
        include_once __DIR__ . '/admin_footer.php';
612
        break;
613
}
614
/**
615
 * @param $lid
616
 * @param $offline
617
 *
618
 * @return bool|null
619
 */
620
function xtubeToggleOffline($lid, $offline)
0 ignored issues
show
xtubeToggleOffline uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
621
{
622
    $message = '';
623
    $offline = (1 == $offline) ? 0 : 1;
624
625
    if (1 == $offline) {
626
        $message = _AM_XOOPSTUBE_TOGGLE_OFFLINE_SUCCESS;
627
    } else {
628
        $message = _AM_XOOPSTUBE_TOGGLE_ONLINE_SUCCESS;
629
    }
630
631
    //    $this_handler   = xoops_getModuleHandler('xoopstube_videos', 'xoopstube');
632
    //    $obj            = $this_handler->get($lid);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
633
    //    $obj->setVar('offline', $offline);
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...
634
    //    if ($this_handler->insert($obj, true)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% 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...
635
    //        redirect_header('main.php', 1, _AM_XOOPSTUBE_TOGGLE_SUCCESS);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
636
    //    } else {
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...
637
    //        redirect_header('main.php', 1, _AM_XOOPSTUBE_TOGGLE_FAILED);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
638
    //    }
639
640
    $sql = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . " SET  offline='" . $offline . "' WHERE lid=" . $lid;
641
642
    if (!$result = $GLOBALS['xoopsDB']->queryF($sql)) {
643
        redirect_header('main.php', 1, _AM_XOOPSTUBE_TOGGLE_FAILED);
644
645
        return false;
646
    } else {
647
        redirect_header('main.php', 1, $message);
648
    }
649
650
    return null;
651
}
652