root/devel-backup/_weblog/rss091.php

Revision 92, 2.6 kB (checked in by sven, 3 years ago)

more RSS HTTP

  • Property svn:eol-style set to native
Line 
1 <?php
2
3     //    ELGG weblog RSS 0.91 page
4
5     // Run includes
6         require("../includes.php");
7         
8         run("profile:init");
9         run("friends:init");
10         run("weblogs:init");
11         
12         global $profile_id;
13         global $individual;
14         global $page_owner;
15         
16         $individual = 1;
17         
18         $output = "";
19         $trackmaxtime = 0;
20         
21         if (isset($page_owner)) {
22             
23             $output .= <<< END
24 <?xml version="1.0"?><!DOCTYPE rss SYSTEM "http://my.netscape.com/publish/formats/rss-0.91.dtd">
25
26 <rss version="0.91">
27 END;
28             $info = db_query("select * from users where ident = $page_owner");
29             if (sizeof($info) > 0) {
30                 $info = $info[0];
31                 $name = htmlentities(stripslashes($info->name));
32                 $username = htmlentities(stripslashes($info->username));
33                 $sitename = sitename;
34                 $mainurl = htmlentities(url . $username . "/weblog/");
35                 $output .= <<< END
36     <channel>
37         <title>$name : Weblog</title>
38         <description>The weblog for $name, hosted on $sitename.</description>
39         <language>en-gb</language>
40         <link>$mainurl</link>
41 END;
42                 $entries = db_query("select * from weblog_posts where weblog = $page_owner and access = 'PUBLIC' order by posted desc limit 10");
43                 if (sizeof($entries) > 0) {
44                     foreach($entries as $entry) {
45                         $title = htmlentities(stripslashes($entry->title));
46                         $trackmaxtime = max($trackmaxtime, $entry->posted);
47                         $link = url . $username . "/weblog/" . $entry->ident . ".html";
48                         $body = (run("weblogs:text:process",stripslashes($entry->body)));
49                         $output .= <<< END
50         <item>
51             <title>$title</title>
52             <link>$link</link>
53             <description>$body</description>
54         </item>
55 END;
56                     }
57                 }
58                 $output .= <<< END
59     </channel>
60 </rss>
61 END;
62             }
63             
64             if ($output) {
65                 header("Pragma: public");
66                 header("Cache-Control: public");
67                 header('Expires: ' . gmdate("D, d M Y H:i:s", (time()+3600)) . " GMT");
68                 
69                 $if_modified_since = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
70                 $if_none_match = preg_replace('/[^0-9a-f]/', '', $_SERVER['HTTP_IF_NONE_MATCH']);
71                 
72                 if (!$trackmaxtime) {
73                     $trackmaxtime = time();
74                 }
75                 
76                 $lm = gmdate("D, d M Y H:i:s", $trackmaxtime) . " GMT";
77                 $etag = md5($output);
78                 
79                 if ($if_modified_since == $lm) {
80                     header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified");
81                     exit;
82                 }
83                 if ($if_none_match == $etag) {
84                     header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified");
85                     exit;
86                 }
87                 
88                 // Send last-modified header to enable if-modified-since requests
89                 if ($tstamp < time()) {
90                     header("Last-Modified: " . $lm);
91                 }
92                 
93                 header("Content-Length: " . strlen($output));
94                 header('ETag: "' . $etag . '"');
95                 
96                 header("Content-type: text/xml");
97                 echo $output;
98             }
99             
100             
101         }
Note: See TracBrowser for help on using the browser.