rss.php 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. header('Content-type: application/xml');
  3. session_start();
  4. $http_host = $_SERVER["HTTP_HOST"];
  5. $doc_root = $_SERVER["DOCUMENT_ROOT"] . "/";
  6. include $doc_root . "functions.php";
  7. $proto = get_protocol();
  8. $con = start_db();
  9. $server = $proto . $http_host;
  10. $lang = select_language($con);
  11. $lserver = $server . "/" . $lang;
  12. $cur_section = "";
  13. $cur_entry = "";
  14. ob_clean();
  15. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  16. ?>
  17. <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  18. <channel>
  19. <title>Iñigo Valentin</title>
  20. <link><?=$lserver?></link>
  21. <atom:link href="<?=$lserver?>/rss.xml" rel="self" type="application/rss+xml" />
  22. <description>TODO 3D art</description>
  23. <category>TODO cgi</category>
  24. <image>
  25. <url><?=$lserver?>/img/logo/cover.png</url>
  26. <title>Iñigo Valentin</title>
  27. <link><?=$lserver?></link>
  28. <width>140</width>
  29. <height>140</height>
  30. </image>
  31. <language><?=$lang?></language>
  32. <?php
  33. $res_date = mysqli_query($con, "(SELECT DATE_FORMAT(dtime, '%a, %d %b %Y %H:%i:%s +0100') AS cdate FROM project_version) UNION (SELECT DATE_FORMAT(dtime, '%a, %d %b %Y %H:%i:%s +0100') AS cdate FROM post) ORDER BY cdate DESC LIMIT 1;");
  34. $row_date = mysqli_fetch_array($res_date);
  35. ?>
  36. <pubDate><?=$row_date["cdate"]?></pubDate>
  37. <?php
  38. $res = mysqli_query($con, "(SELECT 'PROJECT_TITLE' AS type, id, permalink, dtime, DATE_FORMAT(dtime, '%a, %d %b %Y %H:%i:%s +0100') AS cdate, title, text, logo AS image FROM project, project_version WHERE project = project.id) UNION (SELECT 'BLOG_TITLE' AS type, post.id AS id, permalink, dtime, DATE_FORMAT(dtime, '%a, %d %b %Y %H:%i:%s +0100') AS cdate, title, text, image FROM post, post_image WHERE post = post.id) ORDER BY dtime DESC;");
  39. while ($row = mysqli_fetch_array($res)){
  40. ?>
  41. <item>
  42. <title><?=text($con, $row["title"], $lang)?></title>
  43. <category><?=text($con, $row["type"], $lang)?></category>
  44. <?php
  45. $text = html_entity_decode(text($con, $row["text"], $lang));
  46. switch ($row["type"]){
  47. case "PROJECT_TITLE":
  48. ?>
  49. <description>
  50. <![CDATA[
  51. <img src='<?=$lserver?>/img/project/x5/<?=$row["image"]?>' height='160' width='160' />
  52. <?=$text?>
  53. ]]>
  54. </description>
  55. <link><?=$lserver?>/project/<?=$row["permalink"]?></link>
  56. <guid><?=$lserver?>/project/<?=$row["permalink"]?></guid>
  57. <?php
  58. break;
  59. case 'Blog':
  60. ?>
  61. <description>
  62. <![CDATA[
  63. <?php
  64. if ($row['image'] != null){
  65. ?>
  66. <img src='<?=$lserver?>/img/blog/x8/$row[image]' height='224' width='224' />
  67. <?php
  68. }
  69. ?>
  70. <?=$text?>
  71. ]]>
  72. </description>
  73. <link><?=$lserver?>/blog/<?=$row["permalink"]?></link>
  74. <guid><?=$lserver?>/blog/<?=$row["permalink"]?></guid>
  75. <?php
  76. break;
  77. }
  78. ?>
  79. <pubDate><?=$row["cdate"]?></pubDate>
  80. </item>
  81. <?php
  82. }
  83. mysqli_close($con);
  84. ?>
  85. </channel>
  86. </rss>