microblog.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. //Import your config, set some stuff up, then construct the mining laser
  3. extract(json_decode(file_get_contents('../admin/config/main.json'),true));
  4. extract(json_decode(file_get_contents('../admin/config/users.json'),true));
  5. date_default_timezone_set($timezone);
  6. $tiem = date(DATE_RSS);
  7. $today = date("m.d.y");
  8. $atomlink = "http://".$_SERVER["SERVER_NAME"]."/".$basedir.$rssdir."microblog.php";
  9. $newsdir = $_SERVER["DOCUMENT_ROOT"]."/".$basedir.$microblogdir;
  10. $files = glob($newsdir.$today."/*");
  11. $slen = count($files);
  12. $feed = '<?xml version="1.0" encoding="UTF-8"?>
  13. <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  14. <channel>
  15. <atom:link href="'.$atomlink.'" rel="self" type="application/rss+xml" />
  16. <title>'.$htmltitle.'</title>
  17. <description>'.$microblogtitle.' RSS Feed</description>
  18. <link>http://'.$_SERVER['SERVER_NAME'].'/'.$basedir.'</link>
  19. <lastBuildDate>'.$tiem.'</lastBuildDate>
  20. <pubDate>'.$tiem.'</pubDate>';
  21. foreach ($files as $shitpost) {
  22. $storyPubDate = date(DATE_RSS, strtotime(basename($shitpost)));
  23. $contents = file_get_contents($shitpost);
  24. //HAHAHA You thought you needed an XML parser, didn't you?
  25. $theRipper = explode("<",$contents);
  26. $theRipper = explode(">",$theRipper[2]);
  27. $storyTitle = $theRipper[1];
  28. $theRipper = explode('"',$theRipper[0]);
  29. $storyLink = htmlspecialchars($theRipper[1]);
  30. $theRipper = explode("</h3>",$contents);
  31. $theRipper = explode("<hr />",$theRipper[1]);
  32. $storyText = $theRipper[0];
  33. $theRipper = explode("title=\"Posted by ",$contents);
  34. $theRipper = explode('"',$theRipper[1]);
  35. $poster = $theRipper[0];
  36. $email = "null@example.com";
  37. $author = "X";
  38. if(isset($tcmsUsers[$poster])) {
  39. $email = $tcmsUsers[$poster]["email"];
  40. $author = $tcmsUsers[$poster]["fullName"];
  41. }
  42. $feed .= '<item>
  43. <title>'.$storyTitle.'</title>
  44. <description><![CDATA['.$storyText.']]></description>
  45. <link>'.$storyLink.'</link>
  46. <guid isPermaLink="false">'.basename($shitpost).'-'.$_SERVER["SERVER_NAME"].'</guid>
  47. <pubDate>'.$storyPubDate.'</pubDate>
  48. <author>'.$email.' ('.$author.')</author>
  49. </item>';
  50. }
  51. $feed .= ' </channel>
  52. </rss>';
  53. print_r($feed);
  54. ?>