forked from d3m3vilurr/soojung
-
Notifications
You must be signed in to change notification settings - Fork 1
/
trackback.php
82 lines (70 loc) · 2.57 KB
/
trackback.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
<?php
include_once("settings.php");
header("Content-type: text/xml");
if ($_GET["__mode"] == "rss" && isset($_GET["blogid"])) {
$blogid = $_GET["blogid"];
$entry = Entry::getEntry($blogid);
$excerpt = strip_tags($entry->getBody());
if (strlen ($excerpt) > 255)
$excerpt = substring($excerpt,252);
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
echo "<response>\n";
echo "<error>0</error>\n";
echo '<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">'."\n";
echo "<channel>\n";
echo "<title>".$blog_name."</title>\n";
echo "<link>".$blog_baseurl."/trackback.php?blogid=".$_GET["blogid"]."</link>\n";
echo "<description>".$blog_desc."</description>\n";
echo "<item>\n";
echo "<title>".$entry->title."</title>\n";
echo "<link>".$entry->getHref()."</link>\n";
echo "<description>".$excerpt."</description>\n";
echo "</item>\n";
echo "</channel>\n";
echo "</rss></response>\n";
exit;
}
if (isset($_REQUEST["url"]) && isset($_REQUEST["blogid"]) && Entry::exists($_REQUEST["blogid"])) {
$id = $_REQUEST["blogid"];
$url = $_REQUEST["url"];
$title = stripslashes($_REQUEST["title"]);
$excerpt = stripslashes(strip_tags($_REQUEST["excerpt"]));
if (strlen ($excerpt) > 255)
$excerpt = substring($excerpt,252);
$name = stripslashes($_REQUEST["blog_name"]);
# $encoding_title = detect_encoding ($title);
# $encoding_excerpt = detect_encoding ($excerpt);
# $encoding_name = detect_encoding ($name)
# fwrite($fd, $encoding . "\n");
# if ($encoding != "UTF-8") {
# $title = iconv($encoding, "UTF-8", $_POST["title"]);
# $excerpt = iconv($encoding, "UTF-8", $_POST["excerpt"]);
# $name = iconv($encoding, "UTF-8", $_POST["blog_name"]);
# }
$title = convert_to_utf8($title);
$excerpt = convert_to_utf8($excerpt);
$name = convert_to_utf8($name);
if (empty($url)) {
echo '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
echo "<response>\n";
echo "<error>1</error>\n";
echo "<message>url is required</message>\n";
echo "</response>\n";
} else {
Trackback::writeTrackback($id, $url, $name, $title, $excerpt);
$temp = new Usertemplate("index.tpl", 1);
$temp->clearCache();
echo '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
echo "<response>\n";
echo "<error>0</error>\n";
echo "</response>\n";
}
} else {
echo '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
echo "<response>\n";
echo "<error>1</error>\n";
echo "<message>blogid is required. trackback.php?blogid=N form.</message>\n";
echo "</response>\n";
}
# vim: ts=8 sw=2 sts=2 noet
?>