blog.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. extract(json_decode(file_get_contents('../admin/config/main.json'),true));
  3. echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  4. echo "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n";
  5. echo "<channel>\n";
  6. $atomlink = "http://".$_SERVER["SERVER_NAME"]."/".$basedir.$rssdir."blog.php";
  7. echo "<atom:link href=\"".$atomlink."\" rel=\"self\" type=\"application/rss+xml\" />";
  8. echo "\t<title>".$htmltitle."</title>\n";
  9. echo "\t<description>".$blogtitle."</description>\n";
  10. echo "\t<link>http://".$_SERVER["SERVER_NAME"]."/".$basedir."</link>\n";
  11. $tiem = date(DATE_RFC2822, time());
  12. echo "\t<lastBuildDate>$tiem</lastBuildDate>\n";
  13. echo "\t<pubDate>$tiem</pubDate>\n";
  14. $files = glob($_SERVER["DOCUMENT_ROOT"]."/".$basedir.$blogdir."*.post");
  15. $guid = count($files);
  16. //sort by filename
  17. //initialize an array to house sort results
  18. $files2 = array();
  19. $files2 = array_pad($files2,$guid,0);
  20. for ($i=0; $i<$guid; $i++) {
  21. $j = explode('-',basename($files[$i]));
  22. $j = $j[0];
  23. $j = (int)$j;
  24. $j--;
  25. $files2[$j] = $files[$i];
  26. }
  27. $slen = count($files2)-1;
  28. $ctr = 0;
  29. for ($i=$slen; $i>-1; $i--) {
  30. $shitpost=$files2[$i];
  31. if ($ctr > 9) {break;};
  32. $ctr++;
  33. $statz = stat($shitpost);
  34. $uid = $statz['uid'];
  35. $udata = posix_getpwuid($uid);
  36. $user = $udata['name'];
  37. $date = date(DATE_RFC2822, filemtime($shitpost));
  38. $title = substr(strstr(basename($shitpost),'-'),1,-5);
  39. $contents = file_get_contents($shitpost);
  40. echo "\t<item>\n";
  41. echo "\t\t<title>$title</title>\n";
  42. echo "\t\t<description><![CDATA[".$contents."]]>\t\t</description>\n";
  43. echo "\t\t<link>http://teodesian.net/index.php?nav=8&amp;post=".$shitpost."</link>\n";
  44. echo "\t\t<guid isPermaLink=\"false\">$guid-teodesian.net</guid>\n";
  45. echo "\t\t<pubDate>".$date."</pubDate>\n";
  46. echo "\t\t<author>".$user."</author>\n";
  47. echo "\t</item>\n";
  48. $guid--;
  49. }
  50. echo "</channel>\n";
  51. echo "</rss>";
  52. ?>