root/releases/0.1.2a/_files/rss2.php

Revision 7, 2.7 kB (checked in by sven, 3 years ago)

snapshot of elgg 0.1.2a

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