Completed
Branch master (954431)
by Michael
02:43
created

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