root/devel-backup/_files/rss2.php

Revision 246, 1.9 kB (checked in by ben, 3 years ago)

Improved styling for XSL / working in Internet Explorer

  • Property svn:eol-style set to native
Line 
1 <?php
2
3     //    ELGG files RSS 2.0 page
4     // this is now only used for tag-search feeds
5
6     // Run includes
7         require("../includes.php");
8         
9         run("profile:init");
10         run("friends:init");
11         run("files:init");
12         
13         global $profile_id;
14         global $individual;
15         global $page_owner;
16         
17         $individual = 1;
18         
19         $sitename = htmlentities(sitename);
20         
21         $output = "";
22         
23         $tag = trim($_REQUEST['tag']);
24         
25         if (isset($profile_id)) {
26             
27             $rssfiles = sprintf(gettext("Files tagged with %s"),$tag);
28
29             $info = db_query("select * from users where ident = $page_owner");
30             if (sizeof($info) > 0) {
31                 $info = $info[0];
32                 $url = url;
33                 $name = (stripslashes($info->name));
34                 $username = (stripslashes($info->username));
35                 $mainurl = (url . $username . "/files/");
36                 $rssurl = $mainurl . "rss/" . urlencode(trim($_REQUEST['tag']));
37                 $rssdescription = sprintf(gettext("Files for %s, hosted on %s."),$name,$sitename);
38                 $output .= <<< END
39 <?xml-stylesheet type="text/xsl" href="{$rssurl}/rssstyles.xsl"?>
40 <rss version='2.0'   xmlns:dc='http://purl.org/dc/elements/1.1/'>
41     <channel xml:base='$mainurl'>
42         <title><![CDATA[$name : $rssfiles]]></title>
43         <description><![CDATA[$rssdescription]]></description>
44         <link>$mainurl</link>
45 END;
46
47                 $output .= run("files:rss:getitems", array($page_owner, 10, $tag));
48                 
49                 $output .= <<< END
50
51     </channel>
52 </rss>
53 END;
54             }
55             
56             if ($output) {
57                 header("Pragma: public");
58                 header("Cache-Control: public");
59                 header('Expires: ' . gmdate("D, d M Y H:i:s", (time()+3600)) . " GMT");
60                 
61                 $if_none_match = preg_replace('/[^0-9a-f]/', '', $_SERVER['HTTP_IF_NONE_MATCH']);
62                 
63                 $etag = md5($output);
64                 header('ETag: "' . $etag . '"');
65                 
66                 if ($if_none_match == $etag) {
67                     header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified");
68                     exit;
69                 }
70                 
71                 header("Content-Length: " . strlen($output));
72                 
73                 header("Content-type: text/xml");
74                 echo $output;
75             }
76         }
Note: See TracBrowser for help on using the browser.