-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.php
176 lines (151 loc) · 4.93 KB
/
report.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/**
* MyBB 1.6
* Copyright 2010 MyBB Group, All Rights Reserved
*
* Website: http://mybb.com
* License: http://mybb.com/about/license
*
* $Id$
*/
define("IN_MYBB", 1);
define('THIS_SCRIPT', 'report.php');
$templatelist = "report,report_thanks,report_error,report_noreason,forumdisplay_password_wrongpass,forumdisplay_password";
require_once "./global.php";
// Load global language phrases
$lang->load("report");
if($mybb->usergroup['canview'] == 0 || !$mybb->user['uid'])
{
error_no_permission();
}
if($mybb->input['action'] != "do_report")
{
$mybb->input['action'] = "report";
}
$post = get_post($mybb->input['pid']);
if(!$post['pid'])
{
$error = $lang->error_invalidpost;
eval("\$report_error = \"".$templates->get("report_error")."\";");
output_page($report_error);
exit;
}
$forum = get_forum($post['fid']);
if(!$forum)
{
$error = $lang->error_invalidforum;
eval("\$report_error = \"".$templates->get("report_error")."\";");
output_page($report_error);
exit;
}
// Password protected forums ......... yhummmmy!
check_forum_password($forum['parentlist']);
$thread = get_thread($post['tid']);
if($mybb->input['action'] == "report")
{
$plugins->run_hooks("report_start");
$pid = $mybb->input['pid'];
$plugins->run_hooks("report_end");
eval("\$report = \"".$templates->get("report")."\";");
output_page($report);
}
elseif($mybb->input['action'] == "do_report" && $mybb->request_method == "post")
{
// Verify incoming POST request
verify_post_check($mybb->input['my_post_key']);
$plugins->run_hooks("report_do_report_start");
if(!trim($mybb->input['reason']))
{
eval("\$report = \"".$templates->get("report_noreason")."\";");
output_page($report);
exit;
}
if($mybb->settings['reportmethod'] == "email" || $mybb->settings['reportmethod'] == "pms")
{
$query = $db->query("
SELECT DISTINCT u.username, u.email, u.receivepms, u.uid
FROM ".TABLE_PREFIX."moderators m
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=m.id)
WHERE m.fid IN (".$forum['parentlist'].") AND m.isgroup = '0'
");
$nummods = $db->num_rows($query);
if(!$nummods)
{
unset($query);
switch($db->type)
{
case "pgsql":
case "sqlite":
$query = $db->query("
SELECT u.username, u.email, u.receivepms, u.uid
FROM ".TABLE_PREFIX."users u
LEFT JOIN ".TABLE_PREFIX."usergroups g ON (((','|| u.additionalgroups|| ',' LIKE '%,'|| g.gid|| ',%') OR u.usergroup = g.gid))
WHERE (g.cancp=1 OR g.issupermod=1)
");
break;
default:
$query = $db->query("
SELECT u.username, u.email, u.receivepms, u.uid
FROM ".TABLE_PREFIX."users u
LEFT JOIN ".TABLE_PREFIX."usergroups g ON (((CONCAT(',', u.additionalgroups, ',') LIKE CONCAT('%,', g.gid, ',%')) OR u.usergroup = g.gid))
WHERE (g.cancp=1 OR g.issupermod=1)
");
}
}
while($mod = $db->fetch_array($query))
{
$emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
$emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&', '&', get_post_link($post['pid'], $thread['tid'])."#pid".$post['pid']), $thread['subject'], $mybb->input['reason']);
if($mybb->settings['reportmethod'] == "pms" && $mod['receivepms'] != 0 && $mybb->settings['enablepms'] != 0)
{
$pm_recipients[] = $mod['uid'];
}
else
{
my_mail($mod['email'], $emailsubject, $emailmessage);
}
}
if(count($pm_recipients) > 0)
{
$emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
$emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&', '&', get_post_link($post['pid'], $thread['tid'])."#pid".$post['pid']), $thread['subject'], $mybb->input['reason']);
require_once MYBB_ROOT."inc/datahandlers/pm.php";
$pmhandler = new PMDataHandler();
$pm = array(
"subject" => $emailsubject,
"message" => $emailmessage,
"icon" => 0,
"fromid" => $mybb->user['uid'],
"toid" => $pm_recipients
);
$pmhandler->admin_override = true;
$pmhandler->set_data($pm);
// Now let the pm handler do all the hard work.
if(!$pmhandler->validate_pm())
{
// Force it to valid to just get it out of here
$pmhandler->is_validated = true;
$pmhandler->errors = array();
}
$pminfo = $pmhandler->insert_pm();
}
}
else
{
$reportedpost = array(
"pid" => intval($mybb->input['pid']),
"tid" => $thread['tid'],
"fid" => $thread['fid'],
"uid" => $mybb->user['uid'],
"dateline" => TIME_NOW,
"reportstatus" => 0,
"reason" => $db->escape_string(htmlspecialchars_uni($mybb->input['reason']))
);
$db->insert_query("reportedposts", $reportedpost);
$cache->update_reportedposts();
}
$plugins->run_hooks("report_do_report_end");
eval("\$report = \"".$templates->get("report_thanks")."\";");
output_page($report);
}
?>