rss.cgi 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/perl
  2. # This file is part of qorg11 blog
  3. # qorg11 blog is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. # qorg11 blog is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with qorg11 blog. If not, see <https://www.gnu.org/licenses/>.
  13. use SQLite::DB;
  14. my $db = SQLite::DB->new('articles.sqlite');
  15. $db->connect;
  16. my $NumEntradas = $db->select_one_row("select * from blog")->{ID};
  17. my $NumEntradasMax = $db->select_one_row("select * from blog order by id desc")->{ID};
  18. print "Content-type: text/xml";
  19. print "
  20. <?xml version='1.0' encoding='UTF-8' ?>\n
  21. <rss version='2.0'>\n
  22. <channel>\n
  23. <title>qorg11 blog</title>\n
  24. <link>https://qorg.duckdns.org/blog</link>\n
  25. <description>blog qorg11</description>\n";
  26. my $content, $id, $title;
  27. for(my $x = $NumEntradasMax; $x >= $NumEntradas; $x-- ) {
  28. my $entradas = $db->select_one_row("select * from blog where id == $x");
  29. $content = $entradas->{CONTENT};
  30. $id = $entradas->{ID};
  31. $title = $entradas->{TITLE};
  32. $content =~ s/</&lt;/g;
  33. $content =~ s/>/&gt;/g;
  34. print "<item>\n";
  35. print "<title>$title</title>\n";
  36. print "<link>https://qorg.duckdns.org/blog#$id</link>\n";
  37. print "<description>$content</description>\n";
  38. print "</item>";
  39. }
  40. print "</channel>\n";
  41. print "</rss>\n";