root/releases/0.2/profile/rss2.php

Revision 9, 4.1 kB (checked in by sven, 3 years ago)

snapshot of elgg 0.2

Line 
1 <?php
2
3     //    ELGG aggregated RSS 2.0 page
4
5     // Run includes
6         require("../includes.php");
7         
8         run("profile:init");
9         
10         global $profile_id;
11         global $individual;
12         global $page_owner;
13         
14         $individual = 1;
15         
16         $sitename = htmlentities(sitename);
17         
18         header("Content-type: text/xml");
19         
20         if (isset($profile_id)) {
21             echo <<< END
22 <?xml version='1.0' encoding='UTF-8'?>
23 <rss version='2.0'   xmlns:dc='http://purl.org/dc/elements/1.1/'>
24 END;
25             $info = db_query("select * from users where ident = $profile_id");
26             if (sizeof($info) > 0) {
27                 $info = $info[0];
28                 $name = htmlentities(stripslashes($info->name));
29                 $username = htmlentities(stripslashes($info->username));
30                 $mainurl = htmlentities(url . $username . "/");
31                 echo <<< END
32   <channel xml:base='$mainurl'>
33     <title>$name : Activity</title>
34     <description>Activity for $name, hosted on $sitename.</description>
35     <language>en-gb</language>
36     <link>$mainurl</link>
37 END;
38
39             // WEBLOGS
40
41                 if (!isset($_REQUEST['tag'])) {
42                     $entries = db_query("select * from weblog_posts where weblog = $page_owner and access = 'PUBLIC' order by posted desc limit 10");
43                 } else {
44                     $tag = addslashes($_REQUEST['tag']);
45                     $entries = db_query("select weblog_posts.* from tags left join weblog_posts on weblog_posts.ident = tags.ref where weblog_posts.weblog = $page_owner and weblog_posts.access = 'PUBLIC' and tags.tag = '$tag' and tags.tagtype = 'weblog' order by weblog_posts.posted desc limit 10");
46                 }
47                 if (sizeof($entries) > 0) {
48                     foreach($entries as $entry) {
49                         $title = htmlentities(stripslashes($entry->title));
50                         $link = url . $username . "/weblog/" . $entry->ident . ".html";
51                         $body = htmlentities(run("weblogs:text:process",stripslashes($entry->body)));
52                         $pubdate = gmdate("D, d M Y H:i:s T", $entry->posted);
53                         $keywords = db_query("select * from tags where tagtype = 'weblog' and ref = '".$entry->ident."'");
54                         $keywordtags = "";
55                         if (sizeof($keywords) > 0) {
56                             foreach($keywords as $keyword) {
57                                 $keywordtags .= "\n        <dc:subject>".htmlentities(stripslashes($keyword->tag)) . "</dc:subject>";
58                             }
59                         }
60                         echo <<< END
61     <item>
62         <title>$title</title>
63         <link>$link</link>
64         <pubDate>$pubdate</pubDate>$keywordtags
65         <description>$body</description>
66     </item>
67 END;
68                     }
69                 }
70                 
71             // FILES
72             
73                 if (!isset($_REQUEST['tag'])) {
74                     $files = db_query("select * from files where files_owner = $page_owner and access = 'PUBLIC' order by time_uploaded desc limit 10");
75                 } else {
76                     $tag = addslashes($_REQUEST['tag']);
77                     $files = db_query("select files.* from tags left join files on files.ident = tags.ref where files.files_owner = $page_owner and files.access = 'PUBLIC' and tags.tagtype = 'file' and tags.tag = '$tag' order by files.time_uploaded desc limit 10");
78                 }
79                 if (sizeof($files) > 0) {
80                     foreach($files as $file) {
81                         $title = htmlentities(stripslashes($file->title));
82                         $link = url . $username . "/files/" . $file->folder . "/" . $file->ident . "/" . htmlentities(urlencode(stripslashes($file->originalname)));
83                         $description = htmlentities(stripslashes($file->description));
84                         $pubdate = gmdate("D, d M Y H:i:s T", $file->time_uploaded);
85                         $length = (int) $file->size;
86                         $mimetype = run("files:mimetype:determine",$file->location);
87                         if ($mimetype == false) {
88                             $mimetype = "application/octet-stream";
89                         }
90                         $keywords = db_query("select * from tags where tagtype = 'file' and ref = '".$file->ident."'");
91                         $keywordtags = "";
92                         if (sizeof($keywords) > 0) {
93                             foreach($keywords as $keyword) {
94                                 $keywordtags .= "\n        <dc:subject>".htmlentities(stripslashes($keyword->tag)) . "</dc:subject>";
95                             }
96                         }
97                         echo <<< END
98
99     <item>
100         <title>$title</title>
101         <link>$link</link>
102         <enclosure url="$link" length="$length" type="$mimetype" />
103         <pubDate>$pubdate</pubDate>$keywordtags
104         <description>$description</description>
105     </item>
106 END;
107                     }
108                 }
109                 
110                 echo <<< END
111   </channel>
112 </rss>
113 END;
114         }
115     }
Note: See TracBrowser for help on using the browser.