-
Notifications
You must be signed in to change notification settings - Fork 5
/
brokenvideo.php
157 lines (137 loc) · 7.91 KB
/
brokenvideo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/**
* Module: XoopsTube
*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
*
* PHP version 5
*
* @category Module
* @package Xoopstube
* @author XOOPS Development Team
* @copyright 2001-2016 XOOPS Project (https://xoops.org)
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @link https://xoops.org/
* @since 1.0.6
*/
use Xmf\Request;
use XoopsModules\Xoopstube\{
Utility
};
require_once __DIR__ . '/header.php';
$op = Request::getCmd('op', Request::getCmd('op', '', 'POST'), 'GET');
$lid = Request::getInt('lid', Request::getInt('lid', '', 'POST'), 'GET');
$buttonn = mb_strtolower(_MD_XOOPSTUBE_SUBMITBROKEN);
switch (mb_strtolower($op)) {
case $buttonn:
$sender = (is_object($GLOBALS['xoopsUser']) && !empty($GLOBALS['xoopsUser'])) ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
$ip = getenv('REMOTE_ADDR');
$title = Request::getString('title', '', 'POST');
$time = time();
// Check if REG user is trying to report twice
$result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid=' . $lid);
[$count] = $GLOBALS['xoopsDB']->fetchRow($result);
if ($count > 0) {
$ratemessage = _MD_XOOPSTUBE_ALREADYREPORTED;
redirect_header('singlevideo.php?cid=' . (int)$cid . '&lid=' . $lid, 2, $ratemessage);
} else {
$reportid = 0;
$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,
$GLOBALS['xoopsDB']->quoteString($title)
);
if (!$result = $GLOBALS['xoopsDB']->query($sql)) {
$error[] = _MD_XOOPSTUBE_ERROR;
}
$newid = $GLOBALS['xoopsDB']->getInsertId();
// Send notifications
$tags = [];
$tags['BROKENREPORTS_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/main.php?op=listBrokenvideos';
/** @var \XoopsNotificationHandler $notificationHandler */
$notificationHandler = xoops_getHandler('notification');
$notificationHandler->triggerEvent('global', 0, 'video_broken', $tags);
// Send email to the owner of the linkload stating that it is broken
$sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . $lid . ' AND published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() . ')';
$videoArray = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
unset($sql);
/** @var \XoopsMemberHandler $memberHandler */
$memberHandler = xoops_getHandler('member');
$submit_user = $memberHandler->getUser($videoArray['submitter']);
if (is_object($submit_user) && null !== $submit_user) {
$subdate = formatTimestamp($videoArray['date'], $GLOBALS['xoopsModuleConfig']['dateformat']);
$cid = $videoArray['cid'];
$title = htmlspecialchars($videoArray['title'], ENT_QUOTES | ENT_HTML5);
$subject = _MD_XOOPSTUBE_BROKENREPORTED;
$xoopsMailer = xoops_getMailer();
$xoopsMailer->useMail();
$templateDir = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $GLOBALS['xoopsConfig']['language'] . '/mail_template';
$xoopsMailer->setTemplateDir($templateDir);
$xoopsMailer->setTemplate('videobroken_notify.tpl');
$xoopsMailer->setToEmails($submit_user->getVar('email'));
$xoopsMailer->setFromEmail($GLOBALS['xoopsConfig']['adminmail']);
$xoopsMailer->setFromName($GLOBALS['xoopsConfig']['sitename']);
$xoopsMailer->assign('X_UNAME', $submit_user->getVar('uname'));
$xoopsMailer->assign('SITENAME', $GLOBALS['xoopsConfig']['sitename']);
$xoopsMailer->assign('X_ADMINMAIL', $GLOBALS['xoopsConfig']['adminmail']);
$xoopsMailer->assign('X_SITEvidid', _AM_XOOPSTUBE_MOD_VIDID . '/');
$xoopsMailer->assign('X_TITLE', $title);
$xoopsMailer->assign('X_SUB_DATE', $subdate);
$xoopsMailer->assign('X_VIDEOLOAD', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid . '&lid=' . $lid);
$xoopsMailer->setSubject($subject);
$message = $xoopsMailer->send() ? _MD_XOOPSTUBE_BROKENREPORTED : _MD_XOOPSTUBE_ERRORSENDEMAIL;
} else {
$message = _MD_XOOPSTUBE_ERRORSENDEMAIL;
}
redirect_header('singlevideo.php?cid=' . (int)$cid . '&lid=' . $lid, 2, $message);
}
break;
default:
$GLOBALS['xoopsOption']['template_main'] = 'xoopstube_brokenvideo.tpl';
require_once XOOPS_ROOT_PATH . '/header.php';
$catarray['imageheader'] = Utility::renderImageHeader();
$xoopsTpl->assign('catarray', $catarray);
$sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . $lid;
$videoArray = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
unset($sql);
$sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_broken') . ' WHERE lid=' . $lid;
$brokeArray = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
xoops_load('XoopsUserUtility');
if (is_array($brokeArray)) {
$broken['title'] = htmlspecialchars($videoArray['title'], ENT_QUOTES | ENT_HTML5);
$broken['id'] = $brokeArray['reportid'];
$broken['reporter'] = \XoopsUserUtility::getUnameFromId($brokeArray['sender']);
$broken['date'] = Utility::getTimestamp(formatTimestamp($brokeArray['date'], $GLOBALS['xoopsModuleConfig']['dateformat']));
$broken['acknowledged'] = (1 == $brokeArray['acknowledged']) ? _YES : _NO;
$broken['confirmed'] = (1 == $brokeArray['confirmed']) ? _YES : _NO;
$xoopsTpl->assign('broken', $broken);
$xoopsTpl->assign('brokenreport', true);
} else {
if (!is_array($videoArray) || empty($videoArray)) {
$ratemessage = _MD_XOOPSTUBE_THISFILEDOESNOTEXIST;
redirect_header('singlevideo.php?cid=' . (int)$cid . '&lid=' . $lid, 0, $ratemessage);
}
// file info
$video['title'] = htmlspecialchars($videoArray['title'], ENT_QUOTES | ENT_HTML5);
$time = ($videoArray['published'] > 0) ? $videoArray['published'] : $link_arr['updated'];
$video['updated'] = Utility::getTimestamp(formatTimestamp($time, $GLOBALS['xoopsModuleConfig']['dateformat']));
$isUpdated = (0 !== $videoArray['updated']) ? _MD_XOOPSTUBE_UPDATEDON : _MD_XOOPSTUBE_SUBMITDATE;
$video['publisher'] = \XoopsUserUtility::getUnameFromId($videoArray['submitter']);
$xoopsTpl->assign('video_id', $lid);
$xoopsTpl->assign('lang_subdate', $isUpdated);
$xoopsTpl->assign('video', $video);
}
Utility::setNoIndexNoFollow();
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
require_once XOOPS_ROOT_PATH . '/footer.php';
break;
}