-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeed.php
executable file
·67 lines (53 loc) · 2.29 KB
/
feed.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
<?php
header("Content-Type: text/xml; charset='utf-8'");
print("<?xml version='1.0' encoding='UTF-8' ?>");
include "content/siteinformation.php"
?>
<rss version="2.0">
<channel>
<title><?= $sitetitle ?></title>
<description><?= $sitedescription ?></description>
<link><?= $_SERVER['SERVER_NAME'].$root_path ?></link>
<copyright><?= $footertext ?></copyright>
<language><?= strtolower($sitelanguage) ?></language>
<image>
<url><?= $_SERVER['SERVER_NAME'].$root_path."/content/logo.jpg" ?></url>
<title><?= $sitetitle ?></title>
<link><?= $_SERVER['SERVER_NAME'].$root_path ?></link>
<description><?= $sitedescription ?></description>
<width>48</width>
<height>48</height>
</image>
<?php
$file = "content/blog.json";
if(file_exists($file) && filesize($file) > 0){
$handle = fopen($file, "a+");
$contents = fread($handle, filesize($file));
$blogs = json_decode($contents);
fclose($handle);
$postnum = 0;
foreach ($blogs as $blog){
if($fullView == true && $blog->id == $pagename) { echo ''; } else {
if($postnum !== 0) {
echo "<hr>";
}
$postnum += 1;
?>
<item>
<title><?= $blog->title ?></title>
<description>
<?php
echo preg_replace('/\<(img|br)([^>]*)(?<!\/)>/', '<\1\2/>', $blog->text);
?>
</description>
<link><?= $_SERVER['SERVER_NAME'].$root_path.$blog->link ?></link>
<comments><?= $_SERVER['SERVER_NAME'].$root_path.$blog->link."#comments" ?></comments>
<pubDate><?= $blog->datum ?></pubDate>
</item>
<?php
}
}
}
?>
</channel>
</rss>