blogroll.inc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <p class="title">
  2. <a title="RSS" href="sys/rss/blog.php" class="rss"></a>
  3. <?php
  4. echo $config['blogtitle'];
  5. ?>
  6. <hr />
  7. </p>
  8. <?php
  9. if (!empty($_GET['post'])) {
  10. $post=urldecode($_GET['post']);
  11. $statz = stat($post);
  12. $uid = $statz['uid'];
  13. $udata = posix_getpwuid($uid);
  14. $user = $udata['name'];
  15. $date = date("F d Y H:i:s", filemtime($post));
  16. if (stristr($post,'.') != ".post") {
  17. $title = basename($post);
  18. } else {
  19. $title = substr(strstr(basename($post),'-'),1,-5);
  20. }
  21. echo "<h3 class=\"blogtitles\"><a title=permalink href=\"index.php?nav=3&post=".urlencode($post)."\">$title</a></h3>\n";
  22. echo "<em class=\"blogdetail\">Last modified on $date UTC by $user</em><hr />\n\n";
  23. include "$post";
  24. echo "\n<hr /><a style=\"textalign: center;\" href=\"".$_SERVER["PHP_SELF"]."?nav=3\">Back to Blog</a>";
  25. } else {
  26. $offset=0;
  27. if (!empty($_GET['index']) && !is_int($_GET['index'])) {
  28. $offset = 10*$_GET['index'];
  29. }
  30. //slurp up the files
  31. $files = glob("blog/*.post");
  32. $guid = count($files);
  33. //sort by filename
  34. //initialize an array to house sort results
  35. $files2 = array();
  36. $files2 = array_pad($files2,$guid,0);
  37. for ($i=0; $i<$guid; $i++) {
  38. $j = explode('-',basename($files[$i]));
  39. $j = $j[0];
  40. $j = (int)$j;
  41. $j--;
  42. $files2[$j] = $files[$i];
  43. }
  44. $slen = count($files2)-1;
  45. $ctr=0;
  46. $older=0;
  47. for ($i=$slen-$offset; $i>-1; $i--) {
  48. $shitpost=$files2[$i];
  49. //using a counter here to know when to stop, since I don't know how many posts there will be
  50. if ($ctr > 9) {
  51. $older=1;
  52. break;
  53. }
  54. $ctr++;
  55. $statz = stat($shitpost);
  56. $uid = $statz['uid'];
  57. $udata = posix_getpwuid($uid);
  58. $user = $udata['name'];
  59. $date = date("F d Y H:i:s", filemtime($shitpost));
  60. $title = substr(strstr(basename($shitpost),'-'),1,-5);
  61. echo "<h3 class=\"blogtitles\"><a title=permalink href=\"".$_SERVER["PHP_SELF"]."?nav=3&post=".urlencode($shitpost)."\">$title</a></h3>\n";
  62. echo "<em class=\"blogdetail\">Last modified on $date UTC by $user</em><br />\n";
  63. include $shitpost;
  64. echo "<hr />";
  65. };
  66. echo "<table width=\"100%\"><tr><td>";
  67. if ($older) {
  68. $offset=$_GET['index']+1;
  69. echo "<a href=\"".$_SERVER["PHP_SELF"]."?nav=3&index=$offset\">Older Posts</a>";
  70. }
  71. echo "</td><td style=\"text-align: right;\">";
  72. if (!empty($_GET['index'])) {
  73. $offset=$_GET['index']-1;
  74. if ($offset == 0) {
  75. echo "<a href=\"".$_SERVER["PHP_SELF"]."?nav=3\">Newer Posts</a>";
  76. } else {
  77. echo "<a href=\"".$_SERVER["PHP_SELF"]."?nav=3&index=$offset\">Newer Posts</a>";
  78. }
  79. }
  80. echo "</td></tr></table>\n";
  81. }
  82. ?>