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-2013 The XOOPS Project |
||
16 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
17 | * @link http://sourceforge.net/projects/xoops/ |
||
18 | * @since 1.0.6 |
||
19 | * @version $Id$ |
||
20 | */ |
||
21 | |||
22 | require __DIR__ . '/header.php'; |
||
23 | |||
24 | $op = xtubeCleanRequestVars($_REQUEST, 'op', ''); |
||
25 | $lid = xtubeCleanRequestVars($_REQUEST, 'lid', 0); |
||
26 | $lid = intval($lid); |
||
27 | |||
28 | $buttonn = strtolower(_MD_XOOPSTUBE_SUBMITBROKEN); |
||
29 | |||
30 | switch (strtolower($op)) { |
||
31 | case $buttonn: |
||
32 | global $xoopsUser; |
||
0 ignored issues
–
show
|
|||
33 | |||
34 | $sender = (is_object($xoopsUser) && !empty($xoopsUser)) ? $xoopsUser->getVar('uid') : 0; |
||
35 | $ip = getenv('REMOTE_ADDR'); |
||
36 | $title = xtubeCleanRequestVars($_REQUEST, 'title', ''); |
||
37 | $title = $xtubemyts->addslashes($title); |
||
38 | $time = time(); |
||
39 | |||
40 | // Check if REG user is trying to report twice |
||
41 | $result = $xoopsDB->query( |
||
42 | 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xoopstube_broken') . ' WHERE lid=' . intval($lid) |
||
43 | ); |
||
44 | list ($count) = $xoopsDB->fetchRow($result); |
||
45 | if ($count > 0) { |
||
46 | $ratemessage = _MD_XOOPSTUBE_ALREADYREPORTED; |
||
47 | redirect_header('singlevideo.php?cid=' . intval($cid) . '&lid=' . intval($lid), 2, $ratemessage); |
||
48 | exit(); |
||
49 | } else { |
||
50 | $reportid = 0; |
||
51 | $sql = sprintf( |
||
52 | "INSERT INTO %s (reportid, lid, sender, ip, date, confirmed, acknowledged, title ) VALUES ( %u, %u, %u, %s, %u, %u, %u, %s)", |
||
53 | $xoopsDB->prefix('xoopstube_broken'), |
||
54 | $reportid, |
||
55 | $lid, |
||
56 | $sender, |
||
57 | $xoopsDB->quoteString($ip), |
||
58 | $time, |
||
59 | 0, |
||
60 | 0, |
||
61 | $xoopsDB->quoteString($title) |
||
62 | ); |
||
63 | if (!$result = $xoopsDB->query($sql)) { |
||
64 | $error[] = _MD_XOOPSTUBE_ERROR; |
||
65 | } |
||
66 | $newid = $xoopsDB->getInsertId(); |
||
67 | |||
68 | // Send notifications |
||
69 | $tags = array(); |
||
70 | $tags['BROKENREPORTS_URL'] |
||
71 | = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/main.php?op=listBrokenvideos'; |
||
72 | $notification_handler = & xoops_gethandler('notification'); |
||
73 | $notification_handler->triggerEvent('global', 0, 'video_broken', $tags); |
||
74 | |||
75 | // Send email to the owner of the linkload stating that it is broken |
||
76 | $sql |
||
77 | = |
||
78 | 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE lid=' . intval($lid) . ' AND published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() |
||
79 | . ')'; |
||
80 | $video_arr = $xoopsDB->fetchArray($xoopsDB->query($sql)); |
||
81 | unset($sql); |
||
82 | |||
83 | $member_handler = & xoops_gethandler('member'); |
||
84 | $submit_user = & $member_handler->getUser($video_arr['submitter']); |
||
85 | if (is_object($submit_user) && !empty($submit_user)) { |
||
86 | $subdate = formatTimestamp($video_arr['date'], $xoopsModuleConfig['dateformat']); |
||
87 | $cid = $video_arr['cid']; |
||
88 | $title = $xtubemyts->htmlSpecialCharsStrip($video_arr['title']); |
||
89 | $subject = _MD_XOOPSTUBE_BROKENREPORTED; |
||
90 | |||
91 | $xoopsMailer = & getMailer(); |
||
92 | $xoopsMailer->useMail(); |
||
93 | $template_dir = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template'; |
||
94 | $xoopsMailer->setTemplateDir($template_dir); |
||
95 | $xoopsMailer->setTemplate('videobroken_notify.tpl'); |
||
96 | $xoopsMailer->setToEmails($submit_user->getVar('email')); |
||
97 | $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); |
||
98 | $xoopsMailer->setFromName($xoopsConfig['sitename']); |
||
99 | $xoopsMailer->assign("X_UNAME", $submit_user->getVar('uname')); |
||
100 | $xoopsMailer->assign("SITENAME", $xoopsConfig['sitename']); |
||
101 | $xoopsMailer->assign("X_ADMINMAIL", $xoopsConfig['adminmail']); |
||
102 | $xoopsMailer->assign('X_SITEvidid', XOOPS_VIDID . '/'); |
||
103 | $xoopsMailer->assign("X_TITLE", $title); |
||
104 | $xoopsMailer->assign("X_SUB_DATE", $subdate); |
||
105 | $xoopsMailer->assign( |
||
106 | 'X_VIDEOLOAD', |
||
107 | XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/singlevideo.php?cid=' . $cid . '&lid=' . $lid |
||
108 | ); |
||
109 | $xoopsMailer->setSubject($subject); |
||
110 | $message = ($xoopsMailer->send()) ? _MD_XOOPSTUBE_BROKENREPORTED : _MD_XOOPSTUBE_ERRORSENDEMAIL; |
||
111 | } else { |
||
112 | $message = _MD_XOOPSTUBE_ERRORSENDEMAIL; |
||
113 | } |
||
114 | redirect_header('singlevideo.php?cid=' . intval($cid) . '&lid=' . intval($lid), 2, $message); |
||
115 | } |
||
116 | break; |
||
117 | |||
118 | default: |
||
119 | |||
120 | $xoopsOption['template_main'] = 'xoopstube_brokenvideo.tpl'; |
||
121 | include XOOPS_ROOT_PATH . '/header.php'; |
||
122 | |||
123 | $catarray['imageheader'] = xtubeRenderImageHeader(); |
||
124 | $xoopsTpl->assign('catarray', $catarray); |
||
125 | |||
126 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE lid=' . intval($lid); |
||
127 | $video_arr = $xoopsDB->fetchArray($xoopsDB->query($sql)); |
||
128 | unset($sql); |
||
129 | |||
130 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_broken') . ' WHERE lid=' . intval($lid); |
||
131 | $broke_arr = $xoopsDB->fetchArray($xoopsDB->query($sql)); |
||
132 | xoops_load('XoopsUserUtility'); |
||
133 | if (is_array($broke_arr)) { |
||
134 | $broken['title'] = $xtubemyts->htmlSpecialCharsStrip($video_arr['title']); |
||
135 | $broken['id'] = $broke_arr['reportid']; |
||
136 | $broken['reporter'] = XoopsUserUtility::getUnameFromId($broke_arr['sender']); |
||
137 | $broken['date'] = xoopstube(formatTimestamp($broke_arr['date'], $xoopsModuleConfig['dateformat'])); |
||
138 | $broken['acknowledged'] = ($broke_arr['acknowledged'] == 1) ? _YES : _NO; |
||
139 | $broken['confirmed'] = ($broke_arr['confirmed'] == 1) ? _YES : _NO; |
||
140 | $xoopsTpl->assign('broken', $broken); |
||
141 | $xoopsTpl->assign('brokenreport', true); |
||
142 | } else { |
||
143 | if (!is_array($video_arr) || empty($video_arr)) { |
||
144 | $ratemessage = _MD_XOOPSTUBE_THISFILEDOESNOTEXIST; |
||
145 | redirect_header('singlevideo.php?cid=' . intval($cid) . '&lid=' . intval($lid), 0, $ratemessage); |
||
146 | exit(); |
||
147 | } |
||
148 | |||
149 | // file info |
||
150 | $video['title'] = $xtubemyts->htmlSpecialCharsStrip($video_arr['title']); |
||
151 | $time = ($video_arr['published'] > 0) ? $video_arr['published'] : $link_arr['updated']; |
||
152 | $video['updated'] = xtubeGetTimestamp(formatTimestamp($time, $xoopsModuleConfig['dateformat'])); |
||
153 | $is_updated = ($video_arr['updated'] != 0) ? _MD_XOOPSTUBE_UPDATEDON : _MD_XOOPSTUBE_SUBMITDATE; |
||
154 | |||
155 | $video['publisher'] = XoopsUserUtility::getUnameFromId($video_arr['submitter']); |
||
156 | |||
157 | $xoopsTpl->assign('video_id', intval($lid)); |
||
158 | $xoopsTpl->assign('lang_subdate', $is_updated); |
||
159 | $xoopsTpl->assign('video', $video); |
||
160 | } |
||
161 | |||
162 | xtubeSetNoIndexNoFollow(); |
||
163 | |||
164 | $xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname')); |
||
165 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
166 | break; |
||
167 | } |
||
168 |
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state