-
Notifications
You must be signed in to change notification settings - Fork 0
/
wfwcomment.php
66 lines (57 loc) · 2.96 KB
/
wfwcomment.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
<?php
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
include('serendipity_config.inc.php');
if ($_REQUEST['cid'] != '' && $HTTP_RAW_POST_DATA != '') {
$comment = array();
if (!preg_match('@<author[^>]*>(.*)</author[^>]*>@i', $HTTP_RAW_POST_DATA, $name)) {
preg_match('@<dc:creator[^>]*>(.*)</dc:creator[^>]*>@i', $HTTP_RAW_POST_DATA, $name);
}
// this means API comments, which probably are trackbacks, are meant to be ISO-8859-1 7bit only ??
if (isset($name[1]) && !empty($name[1])) {
if (preg_match('@^(.*)\((.*)\)@i', $name[1], $names)) {
if (!function_exists('mb_convert_encoding')) {
$comment['name'] = @utf8_decode($names[2]); // Deprecation in PHP 8.2, removal in PHP 9.0
} else {
$comment['name'] = mb_convert_encoding($names[2], 'ISO-8859-1', 'UTF-8'); // string, to, from
}
if (!function_exists('mb_convert_encoding')) {
$comment['email'] = @utf8_decode($names[1]); // Deprecation in PHP 8.2, removal in PHP 9.0
} else {
$comment['name'] = mb_convert_encoding($names[1], 'ISO-8859-1', 'UTF-8'); // string, to, from
}
} else {
if (!function_exists('mb_convert_encoding')) {
$comment['name'] = @utf8_decode($name[1]); // Deprecation in PHP 8.2, removal in PHP 9.0
} else {
$comment['name'] = mb_convert_encoding($name[1], 'ISO-8859-1', 'UTF-8'); // string, to, from
}
}
}
if (preg_match('@<link[^>]*>(.*)</link[^>]*>@i', $HTTP_RAW_POST_DATA, $link)) {
if (!function_exists('mb_convert_encoding')) {
$comment['url'] = @utf8_decode($link[1]); // Deprecation in PHP 8.2, removal in PHP 9.0
} else {
$comment['url'] = mb_convert_encoding($link[1], 'ISO-8859-1', 'UTF-8'); // string, to, from
}
}
if (preg_match('@<description[^>]*>(.*)</description[^>]*>@ims', $HTTP_RAW_POST_DATA, $description)) {
if (preg_match('@^<!\[CDATA\[(.*)\]\]>@ims', $description[1], $cdata)) {
if (!function_exists('mb_convert_encoding')) {
$comment['comment'] = @utf8_decode($cdata[1]); // Deprecation in PHP 8.2, removal in PHP 9.0
} else {
$comment['comment'] = mb_convert_encoding($cdata[1], 'ISO-8859-1', 'UTF-8'); // string, to, from
}
} else {
if (!function_exists('mb_convert_encoding')) {
$comment['comment'] = @utf8_decode($description[1]); // Deprecation in PHP 8.2, removal in PHP 9.0
} else {
$comment['comment'] = mb_convert_encoding($description[1], 'ISO-8859-1', 'UTF-8'); // string, to, from
}
}
if (!empty($comment['comment'])) {
serendipity_saveComment($_REQUEST['cid'], $comment, 'NORMAL', 'API');
}
}
}
?>