docs-rss.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /*
  3. * $Id: docs-rss.php,v 1.3 2006/03/27 13:08:09 sfox Exp $
  4. */
  5. // Send the appropriate header
  6. header('Content-type: application/rss+xml');
  7. // Start output buffering in order to grab the data from the documentation
  8. // CVS updates file (that is echoed when included) and save to a variable
  9. // instead of echoing it right away.
  10. /* ob_start();
  11. echo '<?xml version=\'1.0\' standalone=\'yes\'?' . '>' . "\n";
  12. include_once 'http://gtk.php.net/manual/en/updates.php';
  13. $xmlstr = ob_get_clean();
  14. $xml = simplexml_load_string($xmlstr);
  15. */
  16. $xmlstr = '<?xml version=\'1.0\' standalone=\'yes\'?>' . "\n"
  17. . '<links>'
  18. . file_get_contents('http://gtk.php.net/manual/en/updates.php')
  19. . '</links>'
  20. ;
  21. $xml = simplexml_load_string($xmlstr);
  22. echo '<?xml version="1.0" encoding="UTF-8"?>';
  23. ?>
  24. <rdf:RDF
  25. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  26. xmlns="http://purl.org/rss/1.0/"
  27. xmlns:dc="http://purl.org/dc/elements/1.1/">
  28. <channel rdf:about="http://gtk.php.net/manual1">
  29. <title>PHP-GTK Manual</title>
  30. <link>http://gtk.php.net/manual1</link>
  31. <description>The PHP-GTK on-line manual</description>
  32. <items>
  33. <rdf:Seq>
  34. <?php
  35. foreach ($xml->a as $link) {
  36. echo ' <rdf:li rdf:resource="' . $link->attributes() . '" />';
  37. echo "\n";
  38. }
  39. ?>
  40. </rdf:Seq>
  41. </items>
  42. </channel>
  43. <?php
  44. foreach ($xml->a as $link) {
  45. foreach ($link->attributes() as $key => $value) {
  46. if ($key == 'date') {
  47. $date = date('Y-m-d', strtotime($value));
  48. } else {
  49. $url = $value;
  50. }
  51. }
  52. ?>
  53. <item rdf:about="<?php echo $url; ?>">
  54. <title><?php echo $link; ?></title>
  55. <link><?php echo $url; ?></link>
  56. <description>Documentation update: <?php echo $link; ?></description>
  57. <dc:date><?php echo $date; ?></dc:date>
  58. </item>
  59. <?php
  60. }
  61. ?>
  62. </rdf:RDF>