Completed
Branch master (ddc2b8)
by Michael
02:46
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
require_once __DIR__ . '/header.php';
22
23
$op  = XoopsRequest::getCmd('op', XoopsRequest::getCmd('op', '', 'POST'), 'GET');
24
$lid = XoopsRequest::getInt('lid', XoopsRequest::getInt('lid', '', 'POST'), 'GET');
25
26
$buttonn = strtolower(_MD_XOOPSTUBE_SUBMITBROKEN);
27
28
switch (strtolower($op)) {
29
    case $buttonn:
30
        $sender = (is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsUser'])) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
31
        $ip     = getenv('REMOTE_ADDR');
32
        $title  = XoopsRequest::getString('title', '', 'POST');
33
        $time   = time();
34
35
        // Check if REG user is trying to report twice
36
        $result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid=' . (int)$lid);
37
        list($count) = $GLOBALS['xoopsDB']->fetchRow($result);
38
        if ($count > 0) {
39
            $ratemessage = _MD_XOOPSTUBE_ALREADYREPORTED;
40
            redirect_header('singlevideo.php?cid=' . (int)$cid . '&amp;lid=' . (int)$lid, 2, $ratemessage);
41
        } else {
42
            $reportid = 0;
43
            $sql      = 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'), $reportid, $lid, $sender, $GLOBALS['xoopsDB']->quoteString($ip), $time, 0, 0,
44
                                $GLOBALS['xoopsDB']->quoteString($title));
45
            if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
46
                $error[] = _MD_XOOPSTUBE_ERROR;
47
            }
48
            $newid = $GLOBALS['xoopsDB']->getInsertId();
49
50
            // Send notifications
51
            $tags                      = array();
52
            $tags['BROKENREPORTS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/main.php?op=listBrokenvideos';
53
            $notificationHandler       = xoops_getHandler('notification');
54
            $notificationHandler->triggerEvent('global', 0, 'video_broken', $tags);
55
56
            // Send email to the owner of the linkload stating that it is broken
57
            $sql       = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . (int)$lid . ' AND published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() . ')';
58
            $video_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
59
            unset($sql);
60
61
            $memberHandler = xoops_getHandler('member');
62
            $submit_user   = $memberHandler->getUser($video_arr['submitter']);
63
            if (is_object($submit_user) && !empty($submit_user)) {
64
                $subdate = formatTimestamp($video_arr['date'], $GLOBALS['xoopsModuleConfig']['dateformat']);
65
                $cid     = $video_arr['cid'];
66
                $title   = $xtubemyts->htmlSpecialCharsStrip($video_arr['title']);
67
                $subject = _MD_XOOPSTUBE_BROKENREPORTED;
68
69
                $xoopsMailer = xoops_getMailer();
70
                $xoopsMailer->useMail();
71
                $template_dir = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/mail_template';
72
                $xoopsMailer->setTemplateDir($template_dir);
73
                $xoopsMailer->setTemplate('videobroken_notify.tpl');
74
                $xoopsMailer->setToEmails($submit_user->getVar('email'));
75
                $xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']);
76
                $xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']);
77
                $xoopsMailer->assign('X_UNAME', $submit_user->getVar('uname'));
78
                $xoopsMailer->assign('SITENAME', $GLOBALS['xoopsConfig']['sitename']);
79
                $xoopsMailer->assign('X_ADMINMAIL', $GLOBALS['xoopsConfig']['adminmail']);
80
                $xoopsMailer->assign('X_SITEvidid', XOOPS_VIDID . '/');
81
                $xoopsMailer->assign('X_TITLE', $title);
82
                $xoopsMailer->assign('X_SUB_DATE', $subdate);
83
                $xoopsMailer->assign('X_VIDEOLOAD', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid . '&amp;lid=' . $lid);
84
                $xoopsMailer->setSubject($subject);
85
                $message = $xoopsMailer->send() ? _MD_XOOPSTUBE_BROKENREPORTED : _MD_XOOPSTUBE_ERRORSENDEMAIL;
86
            } else {
87
                $message = _MD_XOOPSTUBE_ERRORSENDEMAIL;
88
            }
89
            redirect_header('singlevideo.php?cid=' . (int)$cid . '&amp;lid=' . (int)$lid, 2, $message);
90
        }
91
        break;
92
93
    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...
94
95
        $GLOBALS['xoopsOption']['template_main'] = 'xoopstube_brokenvideo.tpl';
96
        include XOOPS_ROOT_PATH . '/header.php';
97
98
        $catarray['imageheader'] = XoopstubeUtility::xtubeRenderImageHeader();
99
        $xoopsTpl->assign('catarray', $catarray);
100
101
        $sql       = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . (int)$lid;
102
        $video_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
103
        unset($sql);
104
105
        $sql       = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid=' . (int)$lid;
106
        $broke_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
107
        xoops_load('XoopsUserUtility');
108
        if (is_array($broke_arr)) {
109
            $broken['title']        = $xtubemyts->htmlSpecialCharsStrip($video_arr['title']);
110
            $broken['id']           = $broke_arr['reportid'];
111
            $broken['reporter']     = XoopsUserUtility::getUnameFromId($broke_arr['sender']);
112
            $broken['date']         = XoopstubeUtility::xtubeGetTimestamp(formatTimestamp($broke_arr['date'], $GLOBALS['xoopsModuleConfig']['dateformat']));
113
            $broken['acknowledged'] = ($broke_arr['acknowledged'] == 1) ? _YES : _NO;
114
            $broken['confirmed']    = ($broke_arr['confirmed'] == 1) ? _YES : _NO;
115
            $xoopsTpl->assign('broken', $broken);
116
            $xoopsTpl->assign('brokenreport', true);
117
        } else {
118
            if (!is_array($video_arr) || empty($video_arr)) {
119
                $ratemessage = _MD_XOOPSTUBE_THISFILEDOESNOTEXIST;
120
                redirect_header('singlevideo.php?cid=' . (int)$cid . '&amp;lid=' . (int)$lid, 0, $ratemessage);
121
            }
122
123
            // file info
124
            $video['title']   = $xtubemyts->htmlSpecialCharsStrip($video_arr['title']);
125
            $time             = ($video_arr['published'] > 0) ? $video_arr['published'] : $link_arr['updated'];
126
            $video['updated'] = XoopstubeUtility::xtubeGetTimestamp(formatTimestamp($time, $GLOBALS['xoopsModuleConfig']['dateformat']));
127
            $is_updated       = ($video_arr['updated'] !== 0) ? _MD_XOOPSTUBE_UPDATEDON : _MD_XOOPSTUBE_SUBMITDATE;
128
129
            $video['publisher'] = XoopsUserUtility::getUnameFromId($video_arr['submitter']);
130
131
            $xoopsTpl->assign('video_id', (int)$lid);
132
            $xoopsTpl->assign('lang_subdate', $is_updated);
133
            $xoopsTpl->assign('video', $video);
134
        }
135
136
        XoopstubeUtility::xtubeSetNoIndexNoFollow();
137
138
        $xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
139
        include XOOPS_ROOT_PATH . '/footer.php';
140
        break;
141
}
142