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

submit.php (29 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
/**
4
 * Module: XoopsTube
5
 *
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * PHP version 5
11
 *
12
 * @category        Module
13
 * @package         Xoopstube
14
 * @author          XOOPS Development Team
15
 * @copyright       2001-2016 XOOPS Project (http://xoops.org)
16
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
17
 * @link            http://xoops.org/
18
 * @since           1.0.6
19
 */
20
21
use Xmf\Request;
22
23
include __DIR__ . '/header.php';
24
include XOOPS_ROOT_PATH . '/header.php';
25
include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
26
27
$mytree = new XoopstubeTree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid');
28
29
global $xoopsModule, $xtubemyts;
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...
30
31
$xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" type="text/css" href="' . $moduleDirName . '/assets/css/xtubestyle.css" />');
32
33
$cid = Request::getInt('cid', 0); //(int) xtubeCleanRequestVars($_REQUEST, 'cid', 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...
34
$lid = Request::getInt('lid', 0); //(int) xtubeCleanRequestVars($_REQUEST, 'lid', 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...
35
36
if (false === XoopstubeUtility::xtubeCheckGroups($cid, 'XTubeSubPerm')) {
37
    redirect_header('index.php', 1, _MD_XOOPSTUBE_NOPERMISSIONTOPOST);
38
}
39
40
if (true === XoopstubeUtility::xtubeCheckGroups($cid, 'XTubeSubPerm')) {
41
    echo '<div class="row">
42
    <div class="col-md-12">';
43
    echo '<ol class="breadcrumb">
44
        <li><a href="index.php">'.$moduleDirName.'</a></li>
45
        <li>'._MD_XOOPSTUBE_SUBMITCATHEAD.'</li>
46
    </ol>
47
    ';
48
    //    if (xtubeCleanRequestVars($_REQUEST, 'submit', 0)) {
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...
49
    if (Request::getString('submit', '')) {
50
        if (false === XoopstubeUtility::xtubeCheckGroups($cid, 'XTubeSubPerm')) {
51
            redirect_header('index.php', 1, _MD_XOOPSTUBE_NOPERMISSIONTOPOST);
52
        }
53
54
        $submitter    = (is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsUser'])) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
55
        $vidsource    = Request::getInt('vidsource', 0, 'POST'); // xtubeCleanRequestVars($_REQUEST, 'vidsource', 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...
56
        $offline      = Request::getInt('offline', 0, 'POST'); // xtubeCleanRequestVars($_REQUEST, 'offline', 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...
57
        $notifypub    = Request::getInt('notifypub', 0, 'POST'); // xtubeCleanRequestVars($_REQUEST, 'notifypub', 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...
58
        $approve      = Request::getInt('approve', 0, 'POST'); // xtubeCleanRequestVars($_REQUEST, 'approve', 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...
59
        $vidrating    = Request::getInt('vidrating', 0, 'POST'); // xtubeCleanRequestVars($_REQUEST, 'vidrating', 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...
60
        $vidid        = Request::getString('vidid', 0, 'POST'); // $xtubemyts->addslashes(ltrim(Request::getInt('vidid', 0, 'POST')));
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...
61
        $title        = Request::getString('title', '', 'POST'); // $xtubemyts->addslashes(ltrim($_REQUEST['title']));
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...
62
        $descriptionb = Request::getString('descriptionb', '', 'POST'); // $xtubemyts->addslashes(ltrim($_REQUEST['descriptionb']));
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...
63
        $publisher    = Request::getString('publisher', '', 'POST'); // $xtubemyts->addslashes(trim($_REQUEST['publisher']));
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...
64
        $time         = Request::getString('time', '', 'POST'); // $xtubemyts->addslashes(ltrim($_REQUEST['time']));
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...
65
        $keywords     = Request::getString('keywords', '', 'POST'); // $xtubemyts->addslashes(trim($_REQUEST['keywords']));
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...
66
        $item_tag     = Request::getString('item_tag', '', 'POST'); // $xtubemyts->addslashes(ltrim($_REQUEST['item_tag']));
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...
67
        $picurl       = Request::getString('picurl', '', 'POST'); // $xtubemyts->addslashes(ltrim($_REQUEST['picurl']));
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...
68
        $date         = time();
69
        $publishdate  = 0;
70
        $ipaddress    = $_SERVER['REMOTE_ADDR'];
71
72
        if (0 == $lid) {
73
            $status      = 0;
74
            $publishdate = 0;
75
            $message     = _MD_XOOPSTUBE_THANKSFORINFO;
76
            if (true === XoopstubeUtility::xtubeCheckGroups($cid, 'XTubeAutoApp')) {
77
                $publishdate = time();
78
                $status      = 1;
79
                $message     = _MD_XOOPSTUBE_ISAPPROVED;
80
            }
81
            $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . '  (lid, cid, title, vidid, submitter, publisher, status, date, hits, rating, votes, comments, vidsource, published, expired, offline, description, ipaddress, notifypub, vidrating, time, keywords, item_tag, picurl) ';
82
            $sql .= " VALUES    ('', $cid, '$title', '$vidid', '$submitter', '$publisher', '$status', '$date', 0, 0, 0, 0, '$vidsource', '$publishdate', 0, '$offline', '$descriptionb', '$ipaddress', '$notifypub', '$vidrating', '$time', '$keywords', '$item_tag', '$picurl')";
83 View Code Duplication
            if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
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...
84
                $_error = $GLOBALS['xoopsDB']->error() . ' : ' . $GLOBALS['xoopsDB']->errno();
85
                XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
86
            }
87
            $newid = $GLOBALS['xoopsDB']->getInsertId();
88
89
            // Add item_tag to Tag-module
90 View Code Duplication
            if ($lid == 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...
91
                $tagupdate = XoopstubeUtility::xtubeUpdateTag($newid, $item_tag);
0 ignored issues
show
Are you sure the assignment to $tagupdate is correct as \XoopstubeUtility::xtube...eTag($newid, $item_tag) (which targets XoopstubeUtility::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...
92
            } else {
93
                $tagupdate = XoopstubeUtility::xtubeUpdateTag($lid, $item_tag);
0 ignored issues
show
Are you sure the assignment to $tagupdate is correct as \XoopstubeUtility::xtubeUpdateTag($lid, $item_tag) (which targets XoopstubeUtility::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...
94
            }
95
96
            // Notify of new link (anywhere) and new link in category
97
            $notificationHandler = xoops_getHandler('notification');
98
99
            $tags               = array();
100
            $tags['VIDEO_NAME'] = $title;
101
            $tags['VIDEO_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid . '&amp;lid=' . $newid;
102
103
            $sql    = 'SELECT title FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' WHERE cid=' . $cid;
104
            $result = $GLOBALS['xoopsDB']->query($sql);
105
            $row    = $GLOBALS['xoopsDB']->fetchArray($result);
106
107
            $tags['CATEGORY_NAME'] = $row['title'];
108
            $tags['CATEGORY_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid;
109
            if (true === XoopstubeUtility::xtubeCheckGroups($cid, 'XTubeAutoApp')) {
110
                $notificationHandler->triggerEvent('global', 0, 'new_video', $tags);
111
                $notificationHandler->triggerEvent('category', $cid, 'new_video', $tags);
112
                redirect_header('index.php', 2, _MD_XOOPSTUBE_ISAPPROVED);
113
            } else {
114
                $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/newvideos.php';
115
                $notificationHandler->triggerEvent('global', 0, 'video_submit', $tags);
116
                $notificationHandler->triggerEvent('category', $cid, 'video_submit', $tags);
117
                if ($notifypub) {
118
                    require_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
119
                    $notificationHandler->subscribe('video', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
120
                }
121
                redirect_header('index.php', 2, _MD_XOOPSTUBE_THANKSFORINFO);
122
            }
123
        } else {
124
            if (true === XoopstubeUtility::xtubeCheckGroups($cid, 'XTubeAutoApp') || $approve === 1) {
125
                $updated = time();
126
                $sql     = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos')
127
                           . " SET cid=$cid, title='$title', vidid='$vidid', publisher='$publisher', updated='$updated', offline='$offline', description='$descriptionb', ipaddress='$ipaddress', notifypub='$notifypub', vidrating='$vidrating', time='$time', keywords='$keywords', item_tag='$item_tag', picurl='$picurl' WHERE lid ="
128
                           . $lid;
129 View Code Duplication
                if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
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...
130
                    $_error = $GLOBALS['xoopsDB']->error() . ' : ' . $GLOBALS['xoopsDB']->errno();
131
                    XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
132
                }
133
134
                $notificationHandler   = xoops_getHandler('notification');
135
                $tags                  = array();
136
                $tags['VIDEO_NAME']    = $title;
137
                $tags['VIDEO_URL']     = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid . '&amp;lid=' . $lid;
138
                $sql                   = 'SELECT title FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' WHERE cid=' . $cid;
139
                $result                = $GLOBALS['xoopsDB']->query($sql);
140
                $row                   = $GLOBALS['xoopsDB']->fetchArray($result);
141
                $tags['CATEGORY_NAME'] = $row['title'];
142
                $tags['CATEGORY_URL']  = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $cid;
143
144
                $notificationHandler->triggerEvent('global', 0, 'new_video', $tags);
145
                $notificationHandler->triggerEvent('category', $cid, 'new_video', $tags);
146
                $_message = _MD_XOOPSTUBE_ISAPPROVED;
147
            } else {
148
                $submitter_array = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query('SELECT submitter FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . (int)$lid));
149
                $modifysubmitter = $GLOBALS['xoopsUser']->uid();
150
                $requestid       = $modifysubmitter;
151
                $requestdate     = time();
152
                $updated         = Request::getInt('up_dated', time(), 'POST'); //xtubeCleanRequestVars($_REQUEST, 'up_dated', time());
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...
153
                if ($modifysubmitter === $submitter_array['submitter']) {
154
                    $sql = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('xoopstube_mod') . ' (requestid, lid, cid, title, vidid, publisher, vidsource, description, modifysubmitter, requestdate, time, keywords, item_tag, picurl)';
155
                    $sql .= " VALUES ('', $lid, $cid, '$title', '$vidid', '$publisher', '$vidsource', '$descriptionb', '$modifysubmitter', '$requestdate', '$time', '$keywords', '$item_tag', '$picurl')";
156 View Code Duplication
                    if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
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...
157
                        $_error = $GLOBALS['xoopsDB']->error() . ' : ' . $GLOBALS['xoopsDB']->errno();
158
                        XoopsErrorHandler_HandleError(E_USER_WARNING, $_error, __FILE__, __LINE__);
159
                    }
160
                } else {
161
                    redirect_header('index.php', 2, _MD_XOOPSTUBE_MODIFYNOTALLOWED);
162
                }
163
164
                $tags                      = array();
165
                $tags['MODIFYREPORTS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=listModReq';
166
                $notificationHandler       = xoops_getHandler('notification');
167
                $notificationHandler->triggerEvent('global', 0, 'video_modify', $tags);
168
169
                $tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php?op=listNewvideos';
170
                $notificationHandler->triggerEvent('global', 0, 'video_submit', $tags);
171
                $notificationHandler->triggerEvent('category', $cid, 'video_submit', $tags);
172
                if ($notifypub) {
173
                    require_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
174
                    $notificationHandler->subscribe('video', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
175
                }
176
                $_message = _MD_XOOPSTUBE_THANKSFORINFO;
177
            }
178
            redirect_header('index.php', 2, $_message);
179
        }
180
    } else {
181
        $approve = Request::getInt('approve', 0, 'POST'); // xtubeCleanRequestVars($_REQUEST, 'approve', 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...
182
183
        // Show disclaimer
184
        if ($GLOBALS['xoopsModuleConfig']['showdisclaimer'] && !Request::getInt('agree', '', 'GET') && 0 == $approve) {
185
            echo '<br><div style="text-align: center;">' . XoopstubeUtility::xtubeRenderImageHeader() . '</div><br>';
186
            echo '<h4>' . _MD_XOOPSTUBE_DISCLAIMERAGREEMENT . '</h4>';
187
            echo '<div>' . $xtubemyts->displayTarea($GLOBALS['xoopsModuleConfig']['disclaimer'], 1, 1, 1, 1, 1) . '</div>';
188
            echo '<form action="submit.php" method="post">';
189
            echo '<div style="text-align: center;">' . _MD_XOOPSTUBE_DOYOUAGREE . '</b><br><br>';
190
            echo '<input type="button" onclick="location=\'submit.php?agree=1\'" class="formButton" value="' . _MD_XOOPSTUBE_AGREE . '" alt="' . _MD_XOOPSTUBE_AGREE . '" />';
191
            echo '&nbsp;';
192
            echo '<input type="button" onclick="location=\'index.php\'" class="formButton" value="' . _CANCEL . '" alt="' . _CANCEL . '" />';
193
            echo '</div></form>';
194
            include XOOPS_ROOT_PATH . '/footer.php';
195
            exit();
196
        }
197
//        echo '<br><div style="text-align: center;">' . XoopstubeUtility::xtubeRenderImageHeader() . '</div><br>';
0 ignored issues
show
Unused Code Comprehensibility introduced by
42% 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...
198
        echo '<div>' . _MD_XOOPSTUBE_SUB_SNEWMNAMEDESC . '</div>';
199
        //        echo "<div class='xoopstube_singletitle'>" . _MD_XOOPSTUBE_SUBMITCATHEAD . "</div>\n";
200
201
        $sql         = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . (int)$lid;
202
        $video_array = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
203
204
        $lid          = $video_array['lid'] ?: 0;
205
        $cid          = $video_array['cid'] ?: 0;
206
        $title        = $video_array['title'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['title']) : '';
207
        $vidid        = $video_array['vidid'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['vidid']) : '';
208
        $publisher    = $video_array['publisher'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['publisher']) : '';
209
        $screenshot   = $video_array['screenshot'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['screenshot']) : '';
210
        $descriptionb = $video_array['description'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['description']) : '';
211
        $published    = $video_array['published'] ?: 0;
212
        $expired      = $video_array['expired'] ?: 0;
213
        $updated      = $video_array['updated'] ?: 0;
214
        $offline      = $video_array['offline'] ?: 0;
215
        $vidsource    = $video_array['vidsource'] ?: 0;
216
        $ipaddress    = $video_array['ipaddress'] ?: 0;
217
        $notifypub    = $video_array['notifypub'] ?: 0;
218
        $vidrating    = $video_array['vidrating'] ?: 1;
219
        $time         = $video_array['time'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['time']) : '0:00:00';
220
        $keywords     = $video_array['keywords'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['keywords']) : '';
221
        $item_tag     = $video_array['item_tag'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['item_tag']) : '';
222
        $picurl       = $video_array['picurl'] ? $xtubemyts->htmlSpecialCharsStrip($video_array['picurl']) : 'http://';
223
224
        $sform = new XoopsThemeForm(_MD_XOOPSTUBE_SUBMITCATHEAD, 'storyform', xoops_getenv('PHP_SELF'));
225
        $sform->setExtra('enctype="multipart/form-data"');
226
227
        XoopstubeUtility::xtubeSetNoIndexNoFollow();
228
229
        // Video title form
230
        $sform->addElement(new XoopsFormText(_MD_XOOPSTUBE_FILETITLE, 'title', 70, 255, $title), true);
231
232
        // Video source form
233
        $vidsource_array  = array(
234
            0   => _MD_XOOPSTUBE_YOUTUBE,
235
            1   => _MD_XOOPSTUBE_METACAFE,
236
            2   => _MD_XOOPSTUBE_IFILM,
237
            3   => _MD_XOOPSTUBE_PHOTOBUCKET,
238
            4   => _MD_XOOPSTUBE_VIDDLER,
239
            100 => _MD_XOOPSTUBE_GOOGLEVIDEO,
240
            101 => _MD_XOOPSTUBE_MYSPAVETV,
241
            102 => _MD_XOOPSTUBE_DAILYMOTION,
242
            103 => _MD_XOOPSTUBE_BLIPTV,
243
            104 => _MD_XOOPSTUBE_CLIPFISH,
244
            105 => _MD_XOOPSTUBE_LIVELEAK,
245
            106 => _MD_XOOPSTUBE_MAKTOOB,
246
            107 => _MD_XOOPSTUBE_VEOH,
247
            108 => _MD_XOOPSTUBE_VIMEO,
248
            109 => _MD_XOOPSTUBE_MEGAVIDEO,
249
            200 => _MD_XOOPSTUBE_XOOPSTUBE
250
        );
251
        $vidsource_select = new XoopsFormSelect(_MD_XOOPSTUBE_VIDSOURCE, 'vidsource', $vidsource);
252
        $vidsource_select->addOptionArray($vidsource_array);
253
        $sform->addElement($vidsource_select, false);
254
255
        // Video code form
256
        $videocode = new XoopsFormText(_MD_XOOPSTUBE_DLVIDID, 'vidid', 70, 512, $vidid);
257
        $videocode->setDescription('<br><span style="font-size: small;">' . _MD_XOOPSTUBE_VIDEO_DLVIDIDDSC . '</span>');
258
        $sform->addElement($videocode, true);
259
        $sform->addElement(new XoopsFormLabel('', _MD_XOOPSTUBE_VIDEO_DLVIDID_NOTE));
260
261
        // Picture url form
262
        $picurl = new XoopsFormText(_MD_XOOPSTUBE_VIDEO_PICURL, 'picurl', 70, 255, $picurl);
263
        $picurl->setDescription('<br><span style="font-weight: normal;">' . _MD_XOOPSTUBE_VIDEO_PICURLNOTE . '</span>');
264
        $sform->addElement($picurl, false);
265
266
        // Video publisher form
267
        $sform->addElement(new XoopsFormText(_MD_XOOPSTUBE_VIDEO_PUBLISHER, 'publisher', 70, 255, $publisher), true);
268
269
        // Category tree
270
        $mytree = new XoopstubeTree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid');
271
272
        $submitcats = array();
273
        $sql        = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' ORDER BY title';
274
        $result     = $GLOBALS['xoopsDB']->query($sql);
275
        while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
276
            if (true === XoopstubeUtility::xtubeCheckGroups($myrow['cid'], 'XTubeSubPerm')) {
277
                $submitcats[$myrow['cid']] = $myrow['title'];
278
            }
279
        }
280
281
        // Video time form
282
        $timeform = new XoopsFormText(_MD_XOOPSTUBE_TIME, 'time', 7, 7, $time);
283
        $timeform->setDescription('<span style="font-size: small;">(h:mm:ss)</span>');
284
        $sform->addElement($timeform, false);
285
286
        // Video category form
287
        ob_start();
288
        $mytree->makeMySelBox('title', 'title', $cid, 0);
289
        $sform->addElement(new XoopsFormLabel(_MD_XOOPSTUBE_CATEGORYC, ob_get_contents()));
290
        ob_end_clean();
291
292
        // Video description form
293
        //        $editor = xtube_getWysiwygForm( _MD_XOOPSTUBE_DESCRIPTIONC, 'descriptionb', $descriptionb, 10, 50, '');
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...
294
        //        $sform -> addElement( $editor, true );
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...
295
296
        $optionsTrayNote = new XoopsFormElementTray(_MD_XOOPSTUBE_DESCRIPTIONC, '<br>');
297 View Code Duplication
        if (class_exists('XoopsFormEditor')) {
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...
298
            $options['name']   = 'descriptionb';
299
            $options['value']  = $descriptionb;
300
            $options['rows']   = 5;
301
            $options['cols']   = '100%';
302
            $options['width']  = '100%';
303
            $options['height'] = '200px';
304
            $editor            = new XoopsFormEditor('', $GLOBALS['xoopsModuleConfig']['form_optionsuser'], $options, $nohtml = false, $onfailure = 'textarea');
305
            $optionsTrayNote->addElement($editor);
306
        } else {
307
            $editor = new XoopsFormDhtmlTextArea('', 'descriptionb', $item->getVar('descriptionb', 'e'), '100%', '100%');
308
            $optionsTrayNote->addElement($editor);
309
        }
310
311
        $sform->addElement($optionsTrayNote, false);
312
313
        // Meta keywords form
314
        $keywords = new XoopsFormTextArea(_MD_XOOPSTUBE_KEYWORDS, 'keywords', $keywords, 5, 50, false);
315
        $keywords->setDescription('<br><span style="font-size: smaller;">' . _MD_XOOPSTUBE_KEYWORDS_NOTE . '</span>');
316
        $sform->addElement($keywords);
317
318
        if ($GLOBALS['xoopsModuleConfig']['usercantag'] == 1) {
319
            // Insert tags if Tag-module is installed
320
            if (XoopstubeUtility::xtubeIsModuleTagInstalled()) {
321
                require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php';
322
                $text_tags = new XoopsFormTag('item_tag', 70, 255, $video_array['item_tag'], 0);
323
                $sform->addElement($text_tags);
324
            }
325
        } else {
326
            $sform->addElement(new XoopsFormHidden('item_tag', $video_array['item_tag']));
327
        }
328
329
        $submitter2 = (is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsUser'])) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
330
        if ($submitter2 > 0) {
331
            $option_tray = new XoopsFormElementTray(_MD_XOOPSTUBE_OPTIONS, '<br>');
332
333
            if (!$approve) {
334
                $notify_checkbox = new XoopsFormCheckBox('', 'notifypub');
335
                $notify_checkbox->addOption(1, _MD_XOOPSTUBE_NOTIFYAPPROVE);
336
                $option_tray->addElement($notify_checkbox);
337
            } else {
338
                $sform->addElement(new XoopsFormHidden('notifypub', 0));
339
            }
340
        }
341
342
        if (true === XoopstubeUtility::xtubeCheckGroups($cid, 'XTubeAppPerm') && $lid > 0) {
343
            $approve_checkbox = new XoopsFormCheckBox('', 'approve', $approve);
344
            $approve_checkbox->addOption(1, _MD_XOOPSTUBE_APPROVE);
345
            $option_tray->addElement($approve_checkbox);
346
        } else {
347
            if (true === XoopstubeUtility::xtubeCheckGroups($cid, 'XTubeAutoApp')) {
348
                $sform->addElement(new XoopsFormHidden('approve', 1));
349
            } else {
350
                $sform->addElement(new XoopsFormHidden('approve', 0));
351
            }
352
        }
353
        $sform->addElement($option_tray);
354
355
        $button_tray = new XoopsFormElementTray('', '');
356
        $button_tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
357
        $button_tray->addElement(new XoopsFormHidden('lid', $lid));
358
359
        $sform->addElement($button_tray);
360
        $sform->display();
361
362
        echo '</div></div>';
363
364
        include XOOPS_ROOT_PATH . '/footer.php';
365
    }
366
} else {
367
    redirect_header('index.php', 2, _MD_XOOPSTUBE_NOPERMISSIONTOPOST);
368
}
369