Completed
Push — master ( 954431...eec6a1 )
by Michael
12s
created

brokenvideo.php (1 issue)

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 dirname(dirname(__DIR__)) . '/mainfile.php';
22
require __DIR__ . '/header.php';
23
24
$op  = XoopsRequest::getCmd('op', XoopsRequest::getCmd('op', '', 'POST'), 'GET');
25
$lid = XoopsRequest::getInt('lid', XoopsRequest::getInt('lid', '', 'POST'), 'GET');
26
27
$buttonn = strtolower(_MD_XOOPSTUBE_SUBMITBROKEN);
28
29
switch (strtolower($op)) {
30
    case $buttonn:
31
        $sender = (is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsUser'])) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
32
        $ip     = getenv('REMOTE_ADDR');
33
        $title  = XoopsRequest::getString('title', '', 'POST');
34
        $time   = time();
35
36
        // Check if REG user is trying to report twice
37
        $result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid=' . (int)$lid);
38
        list($count) = $GLOBALS['xoopsDB']->fetchRow($result);
39
        if ($count > 0) {
40
            $ratemessage = _MD_XOOPSTUBE_ALREADYREPORTED;
41
            redirect_header('singlevideo.php?cid=' . (int)$cid . '&amp;lid=' . (int)$lid, 2, $ratemessage);
42
        } else {
43
            $reportid = 0;
44
            $sql      =
45
                sprintf('INSERT INTO %s (reportid, lid, sender, ip, date, confirmed, acknowledged, title ) VALUES ( %u, %u, %u, %s, %u, %u, %u, %s)', $GLOBALS['xoopsDB']->prefix('xoopstube_broken'),
46
                        $reportid, $lid, $sender, $GLOBALS['xoopsDB']->quoteString($ip), $time, 0, 0, $GLOBALS['xoopsDB']->quoteString($title));
47
            if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
48
                $error[] = _MD_XOOPSTUBE_ERROR;
49
            }
50
            $newid = $GLOBALS['xoopsDB']->getInsertId();
51
52
            // Send notifications
53
            $tags                      = array();
54
            $tags['BROKENREPORTS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/main.php?op=listBrokenvideos';
55
            $notificationHandler       = xoops_getHandler('notification');
56
            $notificationHandler->triggerEvent('global', 0, 'video_broken', $tags);
57
58
            // Send email to the owner of the linkload stating that it is broken
59
            $sql       =
60
                'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . (int)$lid . ' AND published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > '
61
                . time() . ')';
62
            $video_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
63
            unset($sql);
64
65
            $memberHandler = xoops_getHandler('member');
66
            $submit_user   = $memberHandler->getUser($video_arr['submitter']);
67
            if (is_object($submit_user) && !empty($submit_user)) {
68
                $subdate = formatTimestamp($video_arr['date'], $GLOBALS['xoopsModuleConfig']['dateformat']);
69
                $cid     = $video_arr['cid'];
70
                $title   = $xtubemyts->htmlSpecialCharsStrip($video_arr['title']);
71
                $subject = _MD_XOOPSTUBE_BROKENREPORTED;
72
73
                $xoopsMailer = &getMailer();
74
                $xoopsMailer->useMail();
75
                $template_dir = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/mail_template';
76
                $xoopsMailer->setTemplateDir($template_dir);
77
                $xoopsMailer->setTemplate('videobroken_notify.tpl');
78
                $xoopsMailer->setToEmails($submit_user->getVar('email'));
79
                $xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']);
80
                $xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']);
81
                $xoopsMailer->assign('X_UNAME', $submit_user->getVar('uname'));
82
                $xoopsMailer->assign('SITENAME', $GLOBALS['xoopsConfig']['sitename']);
83
                $xoopsMailer->assign('X_ADMINMAIL', $GLOBALS['xoopsConfig']['adminmail']);
84
                $xoopsMailer->assign('X_SITEvidid', XOOPS_VIDID . '/');
85
                $xoopsMailer->assign('X_TITLE', $title);
86
                $xoopsMailer->assign('X_SUB_DATE', $subdate);
87
                $xoopsMailer->assign('X_VIDEOLOAD', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid . '&amp;lid=' . $lid);
88
                $xoopsMailer->setSubject($subject);
89
                $message = $xoopsMailer->send() ? _MD_XOOPSTUBE_BROKENREPORTED : _MD_XOOPSTUBE_ERRORSENDEMAIL;
90
            } else {
91
                $message = _MD_XOOPSTUBE_ERRORSENDEMAIL;
92
            }
93
            redirect_header('singlevideo.php?cid=' . (int)$cid . '&amp;lid=' . (int)$lid, 2, $message);
94
        }
95
        break;
96
97
    default:
0 ignored issues
show
The default body in a switch statement must start on the line following the statement.

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

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


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

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

Loading history...
98
99
        $xoopsOption['template_main'] = 'xoopstube_brokenvideo.tpl';
100
        include XOOPS_ROOT_PATH . '/header.php';
101
102
        $catarray['imageheader'] = XoopstubeUtilities::xtubeRenderImageHeader();
103
        $xoopsTpl->assign('catarray', $catarray);
104
105
        $sql       = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . (int)$lid;
106
        $video_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
107
        unset($sql);
108
109
        $sql       = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid=' . (int)$lid;
110
        $broke_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
111
        xoops_load('XoopsUserUtility');
112
        if (is_array($broke_arr)) {
113
            $broken['title']        = $xtubemyts->htmlSpecialCharsStrip($video_arr['title']);
114
            $broken['id']           = $broke_arr['reportid'];
115
            $broken['reporter']     = XoopsUserUtility::getUnameFromId($broke_arr['sender']);
116
            $broken['date']         = XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($broke_arr['date'], $GLOBALS['xoopsModuleConfig']['dateformat']));
117
            $broken['acknowledged'] = ($broke_arr['acknowledged'] == 1) ? _YES : _NO;
118
            $broken['confirmed']    = ($broke_arr['confirmed'] == 1) ? _YES : _NO;
119
            $xoopsTpl->assign('broken', $broken);
120
            $xoopsTpl->assign('brokenreport', true);
121
        } else {
122
            if (!is_array($video_arr) || empty($video_arr)) {
123
                $ratemessage = _MD_XOOPSTUBE_THISFILEDOESNOTEXIST;
124
                redirect_header('singlevideo.php?cid=' . (int)$cid . '&amp;lid=' . (int)$lid, 0, $ratemessage);
125
            }
126
127
            // file info
128
            $video['title']   = $xtubemyts->htmlSpecialCharsStrip($video_arr['title']);
129
            $time             = ($video_arr['published'] > 0) ? $video_arr['published'] : $link_arr['updated'];
130
            $video['updated'] = XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($time, $GLOBALS['xoopsModuleConfig']['dateformat']));
131
            $is_updated       = ($video_arr['updated'] !== 0) ? _MD_XOOPSTUBE_UPDATEDON : _MD_XOOPSTUBE_SUBMITDATE;
132
133
            $video['publisher'] = XoopsUserUtility::getUnameFromId($video_arr['submitter']);
134
135
            $xoopsTpl->assign('video_id', (int)$lid);
136
            $xoopsTpl->assign('lang_subdate', $is_updated);
137
            $xoopsTpl->assign('video', $video);
138
        }
139
140
        XoopstubeUtilities::xtubeSetNoIndexNoFollow();
141
142
        $xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
143
        include XOOPS_ROOT_PATH . '/footer.php';
144
        break;
145
}
146