forked from Phorum/Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.php
148 lines (127 loc) · 6.83 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
<?php
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2011 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
// //
////////////////////////////////////////////////////////////////////////////////
define('phorum_page','report');
require_once './common.php';
require_once PHORUM_PATH.'/include/api/mail.php';
require_once PHORUM_PATH.'/include/api/format/messages.php';
// set all our URL's ... we need these earlier
phorum_build_common_urls();
// checking read-permissions
if(!phorum_check_read_common()) {
return;
}
$report = false;
$template = "report";
$message=array();
$message_id = 0;
// get the message
if (isset($PHORUM["args"][1]) && is_numeric($PHORUM["args"][1])) {
$message_id = $PHORUM["args"][1];
$message = $PHORUM['DB']->get_message($message_id);
} else {
phorum_api_redirect(PHORUM_LIST_URL);
}
if (is_array($message) && count($message))
{
// check for report requests
if (!empty($_POST["cancel"]))
{
return phorum_api_redirect(phorum_api_url(
PHORUM_FOREIGN_READ_URL,
$message["forum_id"], $message["thread"], $message['message_id']
));
}
if (!empty($_POST["report"]))
{
if ($PHORUM["DATA"]["LOGGEDIN"]){
if (empty($_POST["explanation"])){
$_POST["explanation"] = "<" . $PHORUM["DATA"]["LANG"]["None"] . ">";
}
$mail_users = phorum_api_user_list_moderators($PHORUM['forum_id'], $PHORUM['email_ignore_admin'], TRUE);
if(count($mail_users)){
$mail_data = array(
"mailmessage" => $PHORUM["DATA"]["LANG"]['ReportPostEmailBody'],
"mailsubject" => $PHORUM["DATA"]["LANG"]['ReportPostEmailSubject'],
"forumname" => $PHORUM["DATA"]["NAME"],
"reportedby" => $PHORUM["user"]["display_name"],
"author" => $message["author"],
"subject" => $message["subject"],
"body" => wordwrap($message["body"], 72),
"ip" => $message["ip"],
"raw_date" => $message["datestamp"],
"date" => phorum_api_format_date($PHORUM["short_date_time"], $message["datestamp"]),
"explanation" => wordwrap($_POST["explanation"], 72),
"url" => phorum_api_url(PHORUM_READ_URL, $message["thread"], $message_id),
"delete_url" => phorum_api_url(PHORUM_MODERATION_URL, PHORUM_DELETE_MESSAGE, $message_id),
"hide_url" => phorum_api_url(PHORUM_MODERATION_URL, PHORUM_HIDE_POST, $message_id),
"edit_url" => phorum_api_url(PHORUM_POSTING_URL, 'moderation', $message_id),
"reporter_url"=> phorum_api_url(PHORUM_PROFILE_URL, $PHORUM["user"]["user_id"]),
"message" => $message
);
if (isset($_POST[PHORUM_SESSION_LONG_TERM])) {
// strip any auth info from the created urls
$mail_data["url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["url"]);
$mail_data["delete_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["delete_url"]);
$mail_data["hide_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["hide_url"]);
$mail_data["edit_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["edit_url"]);
$mail_data["reporter_url"] = preg_replace("!,{0,1}" . PHORUM_SESSION_LONG_TERM . "=" . urlencode($_POST[PHORUM_SESSION_LONG_TERM]) . "!", "", $mail_data["reporter_url"]);
}
if (isset($PHORUM["hooks"]["report"]))
$mail_data = phorum_api_hook("report", $mail_data);
phorum_api_mail($mail_users, $mail_data);
$PHORUM["DATA"]["URL"]["REDIRECT"] = phorum_api_url(
PHORUM_FOREIGN_READ_URL,
$message["forum_id"], $message["thread"], $message['message_id']
);
$PHORUM["DATA"]["BACKMSG"]=$PHORUM["DATA"]["LANG"]["BackToThread"];
$PHORUM["DATA"]["OKMSG"]=$PHORUM["DATA"]["LANG"]["ReportPostSuccess"];
$template="message";
$report = true;
}
}
else{
$PHORUM["DATA"]["ReportPostMessage"] = $PHORUM["DATA"]["LANG"]['ReportPostNotAllowed'];
}
}
// format message
list($message) = phorum_api_format_messages(array($message));
$PHORUM["DATA"]["PostSubject"] = $message["subject"];
$PHORUM["DATA"]["PostAuthor"] = $message["author"];
$PHORUM["DATA"]["PostBody"] = $message["body"];
$PHORUM["DATA"]["raw_PostDate"] = $message["datestamp"];
$PHORUM["DATA"]["PostDate"] = phorum_api_format_date($PHORUM["short_date_time"], $message["datestamp"]);
$PHORUM["DATA"]["ReportURL"] = phorum_api_url(PHORUM_REPORT_URL, $message_id);
// if the report was not successfully sent, keep whatever explanation they gave already
if (isset($_POST["explanation"]) && !$report) {
$PHORUM["DATA"]["explanation"] = $_POST["explanation"];
}
else {
$PHORUM["DATA"]["explanation"] = "";
}
} else {
$PHORUM["DATA"]["ERROR"] = $PHORUM['DATA']['LANG']['MessageNotFound'];
$template='message';
}
$PHORUM['DATA']['BREADCRUMBS'][] = array(
'URL' => '',
'TEXT' => $PHORUM['DATA']['LANG']['Report'],
'TYPE' => 'report'
);
phorum_api_output($template);
?>