forked from coppermine-gallery/cpg1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreport_file.php
358 lines (316 loc) · 14 KB
/
report_file.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2016 Coppermine Dev Team
v1.0 originally written by Gregory Demar
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3
as published by the Free Software Foundation.
********************************************
Coppermine version: 1.6.01
$HeadURL$
**********************************************/
define('IN_COPPERMINE', true);
define('REPORT_FILE_PHP', true);
require('include/init.inc.php');
require('include/mailer.inc.php');
if ((!$CONFIG['report_post']==1) || (!USER_CAN_SEND_ECARDS)) {
cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
}
$icon_array['ok'] = cpg_fetch_icon('ok', 1);
$icon_array['report'] = cpg_fetch_icon('report', 2);
if ($CONFIG['enable_smilies']) {
include("include/smilies.inc.php");
}
function get_post_var($name, $default = '')
{
$superCage = Inspekt::makeSuperCage();
if ($superCage->post->keyExists($name)) {
return get_magic_quotes_gpc() ? stripslashes_deep($superCage->post->noTags($name)) : $superCage->post->noTags($name);
} else {
return $default;
}
}
$pid = $superCage->get->getInt('pid');
$cid = $superCage->get->getInt('msg_id');
$what = $superCage->get->getAlpha('what');
$type = $lang_report_php['type_file'];
$template = $template_report;
$sender_name = get_post_var('sender_name', USER_NAME ? USER_NAME : (isset($USER['name']) ? $USER['name'] : ''));
if (defined('UDB_INTEGRATION')AND USER_ID) {
$USER_DATA = array_merge($USER_DATA,$cpg_udb->get_user_infos(USER_ID));
}
if ($USER_DATA['user_email']) {
$sender_email = $USER_DATA['user_email'];
$sender_box = $sender_email;
$sender_name = $USER_DATA['user_name'];
$sender_name_box = $sender_name;
} else {
$sender_email = get_post_var('sender_email',$USER['email'] ? $USER['email'] : '');
$sender_box = "<input type=\"text\" class=\"textinput\" value=\"$sender_email\" name=\"sender_email\" style=\"width: 100%;\" />";
$sender_name = get_post_var('sender_name',$USER['name'] ? $USER['name'] : '');
$sender_name_box = "<input type=\"text\" class=\"textinput\" value=\"$sender_name\" name=\"sender_name\" style=\"width: 100%;\" />";
}
$subject = get_post_var('subject');
$message = get_post_var('message');
$sender_email_warning = '';
$form_action="$CPG_PHP_SELF?pid=$pid";
// Get picture thumbnail url
$result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} p WHERE pid='$pid' $FORBIDDEN_SET");
if (!$result->numRows()) {
cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
}
$row = $result->fetchArray(true);
$thumb_pic_url = get_pic_url($row, 'thumb');
if ($what == 'comment') {
$result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, approval FROM {$CONFIG['TABLE_COMMENTS']} WHERE msg_id='$cid' AND approval = 'YES' AND pid='$pid'");
if (!$result->numRows()) {
cpg_die(ERROR, $lang_errors['non_exist_comment'], __FILE__, __LINE__);
}
$row = $result->fetchArray(true);
$comment = bb_decode($row['msg_body']);
if ($CONFIG['enable_smilies']) {
$comment = process_smilies($comment);
}
$msg_author = $row['msg_author'];
$comment_field_name = sprintf($lang_report_php['comment_field_name'], $msg_author);
$type = $lang_report_php['type_comment'];
$template = $template_report_comment_email;
$form_action ="$CPG_PHP_SELF?pid=$pid&msg_id=$cid&what=comment";
//template_extract_block($template_report_form, 'reason_missing'); //need help to toggle off reason(missing) since doesn't apply to comments
} else {
//template_extract_block($template_report_form, 'display_comment'); //need help remove comment preview when reporting picture
}
// Check supplied email address
$valid_sender_email = Inspekt::isEmail($sender_email);
$invalid_email = '<div class="cpg_message_error">' . $lang_report_php['invalid_email'] . '</div>';
if (!$valid_sender_email && $superCage->post->keyExists('subject')) {
$sender_email_warning = $invalid_email;
}
// Create and send the e-card
if ($superCage->post->keyExists('subject') && $valid_sender_email) {
$gallery_url_prefix = $CONFIG['ecards_more_pic_target']. (substr($CONFIG['ecards_more_pic_target'], -1) == '/' ? '' : '/');
if ($CONFIG['make_intermediate'] && max($row['pwidth'], $row['pheight']) > $CONFIG['picture_width']) {
$n_picname = get_pic_url($row, 'normal');
} else {
$n_picname = get_pic_url($row, 'fullsize');
}
if (!stristr($n_picname, 'http:')) {
$n_picname = $gallery_url_prefix . $n_picname;
}
//output list of reasons checkmarked
$reasons = $lang_report_php['reasons_list_heading'] . $LINEBREAK;
if ($superCage->post->keyExists('reason')) {
foreach(get_post_var('reason') as $value) {
$value = $lang_report_php["$value"];
$reason_list .= "$value, ";
}
} else {
$reasons .= "{$lang_report_php['no_reason_given']}";
}
$reason_list = substr($reason_list, 0, -2); //remove trailing comma and space
$reasons .= $reason_list;
$msg_content = nl2br(strip_tags($message));
$data = array(
'sn' => $sender_name,
'se' => $sender_email,
'p' => $n_picname,
'su' => $subject,
'm' => $message,
'r' => $reasons,
'c' => $comment,
'cid' => $cid,
'pid' => $pid,
't' => $what,
);
$encoded_data = urlencode(base64_encode(serialize($data)));
$params = array('{LANG_DIR}' => $lang_text_dir,
'{TITLE}' => sprintf($lang_report_php['report_subject'], $sender_name, $type),
'{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
'{VIEW_REPORT_TGT}' => "{$gallery_url_prefix}displayreport.php?data=$encoded_data",
'{VIEW_REPORT_LNK}' => $lang_report_php['view_report'],
'{VIEW_REPORT_LNK_PLAINTEXT}' => $lang_report_php['view_report_plaintext'],
'{PIC_URL}' => $n_picname,
'{URL_PREFIX}' => $gallery_url_prefix,
'{PIC_TGT}' => "{$CONFIG['ecards_more_pic_target']}displayimage.php?pid=" . $pid,
'{SUBJECT}' => $subject,
'{MESSAGE}' => $msg_content,
'{PLAINTEXT_MESSAGE}' => $message,
'{SENDER_EMAIL}' => $sender_email,
'{SENDER_NAME}' => $sender_name,
'{VIEW_MORE_TGT}' => $CONFIG['ecards_more_pic_target'],
'{VIEW_MORE_LNK}' => $lang_report_php['view_more_pics'],
'{REASON}' => $reasons,
'{COMMENT}' => $comment,
'{COMMENT_ID}' => $cid,
'{VIEW_COMMENT_LNK}' => $lang_report_php['view_comment'],
'{COMMENT_TGT}' => "{$CONFIG['ecards_more_pic_target']}displayimage.php?pid=$pid#comment$cid",
'{PID}' => $pid,
);
$message = template_eval($template, $params);
$plaintext_message = template_eval($template_report_plaintext, $params);
$tempTime = time();
$message .= sprintf($lang_report_php['report_footer'], $sender_name, $raw_ip, localised_date(-1,$lang_date['comment']));
$subject = sprintf($lang_report_php['report_subject'], $sender_name, $type);
$result = cpg_mail('admin', $subject, $message, 'text/html', $sender_name, $sender_email, $plaintext_message);
/*//write log
if ($CONFIG['log_ecards'] == 1) {
$result_log = cpg_db_query("INSERT INTO {$CONFIG['TABLE_ECARDS']} (sender_name, sender_email, recipient_name, recipient_email, link, date, sender_ip) VALUES ('$sender_name', '$sender_email', '$recipient_name', '$recipient_email', '$encoded_data', '$tempTime', '$raw_ip')");
}*/
if (!USER_ID) {
$USER['name'] = $sender_name;
$USER['email'] = $sender_email;
}
if ($result) {
pageheader($lang_report_php['title'], "<meta http-equiv=\"refresh\" content=\"3;url=displayimage.php?pid={$pid}\" />");
msg_box($lang_cpg_die[INFORMATION], $lang_report_php['send_success'], $lang_common['continue'], "displayimage.php?pid={$pid}");
pagefooter();
exit;
} else {
cpg_die(ERROR, $lang_report_php['send_failed'], __FILE__, __LINE__);
}
}
if ($superCage->post->keyExists('submit')) {
//Check if the form token is valid
if(!checkFormToken()){
cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__);
}
}
pageheader($lang_report_php['title']);
echo <<< EOT
<form method="post" name="post" id="cpgform" action="$form_action">
EOT;
starttable("100%", $icon_array['report'] . $lang_report_php['title'], 3);
echo <<<EOT
<tr>
<td class="tableh2" colspan="2"><strong>{$lang_report_php['from']}</strong></td>
<!-- BEGIN display_thumbnail -->
<td rowspan="6" align="center" valign="top" class="tableb">
<img src="$thumb_pic_url" alt="" vspace="8" border="0" class="image" /><br />
</td>
<!-- END display_thumbnail -->
</tr>
<tr>
<td class="tableb" valign="top" width="40%">
{$lang_report_php['your_name']}<br />
</td>
<td valign="top" class="tableb" width="60%">
{$sender_name_box}
</td>
</tr>
<tr>
<td class="tableb" valign="top" width="40%">
{$lang_report_php['your_email']}<br />
</td>
<td valign="top" class="tableb" width="60%">
{$sender_box}
{$sender_email_warning}
</td>
</tr>
<tr>
<td class="tableh2" colspan="2"><strong>{$lang_report_php['to']}</strong></td>
</tr>
<tr>
<td class="tableb" valign="top" width="40%" colspan="2">
{$lang_report_php['administrator']}<br />
</td>
</tr>
<tr>
<td class="tableh2" colspan="3"><strong>{$lang_report_php['refers_to']}:</strong></td>
</tr>
<tr>
<td class="tableb" colspan="3">
<a href="{$CONFIG['ecards_more_pic_target']}displayimage.php?pid={$pid}">
{$CONFIG['ecards_more_pic_target']}displayimage.php?pid={$pid}</a>
</td>
</tr>
<!-- BEGIN display_comment -->
<tr>
<td class="tableh2" valign="top" width="40%" colspan="3"><strong>$comment_field_name</strong></td>
</tr>
<tr>
<td class="tableb" valign="top" width="40%" colspan="3">
$comment<br />
</td>
</tr>
<!-- END display_comment -->
<tr>
<td class="tableh2" colspan="3"><strong>{$lang_report_php['subject']}</strong></td>
</tr>
<tr>
<td class="tableb" colspan="3">
<input type="text" class="textinput" name="subject" value="$subject" style="width: 100%;" /><br />
</td>
</tr>
<tr>
<td class="tableh2" colspan="3"><strong>{$lang_report_php['reason']}</strong></td>
</tr>
<tr>
<td class="tableb" colspan="3">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
</tr>
<tr>
<!-- BEGIN reason_obscene -->
<td>
<input value="obscene" type="checkbox" name="reason[]" id="obscene" />
<label for="obscene" class="clickable_option">{$lang_report_php['obscene']}</label>
</td>
<!-- END reason_obscene -->
<!-- BEGIN reason_offensive -->
<td>
<input value="offensive" type="checkbox" name="reason[]" id="offensive" />
<label for="offensive" class="clickable_option">{$lang_report_php['offensive']}</label>
</td>
<!-- END reason_offensive -->
<!-- BEGIN reason_misplaced -->
<td>
<input value="misplaced" type="checkbox" name="reason[]" id="misplaced" />
<label for="misplaced" class="clickable_option">{$lang_report_php['misplaced']}</label>
</td>
<!-- END reason_misplaced -->
<!-- BEGIN reason_missing -->
<td>
<input value="missing" type="checkbox" name="reason[]" id="missing" />
<label for="missing" class="clickable_option">{$lang_report_php['missing']}</label>
</td>
<!-- END reason_missing -->
<!-- BEGIN reason_issue -->
<td>
<input value="issue" type="checkbox" name="reason[]" id="issue" />
<label for="issue" class="clickable_option">{$lang_report_php['issue']}</label>
</td>
<!-- END reason_issue -->
<!-- BEGIN reason_other -->
<td>
<input value="other" type="checkbox" name="reason[]" id="other" />
<label for="other" class="clickable_option">{$lang_report_php['other']}</label>
</td>
<!-- END reason_other -->
</tr>
</table>
</td>
</tr>
<tr>
<td class="tableh2" colspan="3"><strong>{$lang_report_php['message']}</strong></td>
</tr>
<tr>
<td class="tableb" colspan="3" valign="top">
<textarea name="message" class="textinput" rows="8" cols="40" onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" style="width: 100%;">$message</textarea><br /><br />
</td>
</tr>
<tr>
<td colspan="3" align="center" class="tablef">
<button type="submit" class="button" name="submit" id="submit" value="{$lang_report_php['title']}">{$icon_array['ok']}{$lang_report_php['title']}</button>
</td>
</tr>
EOT;
endtable();
list($timestamp, $form_token) = getFormToken();
echo <<< EOT
<input type="hidden" name="form_token" value="{$form_token}" />
<input type="hidden" name="timestamp" value="{$timestamp}" />
</form>
EOT;
pagefooter();
//EOF