summaryrefslogtreecommitdiff
path: root/modules/headlineRSS10.module
blob: eacd7c7d5b4c58da5528b50a4f059955378f923e (plain)
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
<?php

// RSS 1.0 headline exporter (v0.1)
//
// Kristjan Jansen -- kika@sloleht.ee

$module = array("export" => "headlineRSS10_export");

include_once "includes/common.inc";
include_once "modules/backend.class";

function headlineRSS10_export($uri) {
  global $site_name, $site_url, $status, $HTTP_REFERER, $HTTP_USER_AGENT;

  if ($uri[1] == "headlinesRSS10.rdf") {
    watchdog("message", "grabbed 'headlinesRSS10.rdf' - referring url: $HTTP_REFERER - user agent: $HTTP_USER_AGENT");

    header("Content-Type: text/plain");

    print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
    print "<rdf:RDF\n";

    print "xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n";
    print "xmlns=\"http://purl.org/rss/1.0/\">\n\n";

    print "<channel rdf:about=\"".$site_url."export/headlinesRSS10.rdf\">\n";
    print "   <title>$site_name</title>\n";
    print "   <link>$site_url</link>\n";
    print "   <description>$site_name</description>\n";


    print "  <items>\n";
    print "    <rdf:Seq>\n";

    $result = db_query("SELECT * FROM nodes WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");

    while ($node = db_fetch_object($result)) {
      print "      <rdf:li resource=\"". $site_url ."node.php?id=$node->nid\" />\n";

    }

    print "    </rdf:Seq>\n";
    print "  </items>\n";
    print "</channel>\n\n";

    $result = db_query("SELECT * FROM node WHERE type = 'story' AND status = '$status[posted]' ORDER BY timestamp DESC LIMIT 10");

    while ($node = db_fetch_object($result)) {
      print "<item rdf:about=\"".$site_url ."node.php?id=$node->nid\">\n";
      print "  <title>". check_export($node->title) ."</title>\n";
      print "  <link>". $site_url ."node.php?id=$node->nid</link>\n";

      if ($node->abstract)
      print "  <description>". check_output($node->abstract, 1) ."</description>\n";

      print "</item>\n";
    }

    print "</rdf:RDF>\n";
  }
}

?>