Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

get_post.php 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. require_once('../includes/config.php');
  3. if(isset($_POST))
  4. {
  5. $own_blog = false;
  6. $userID = rawurldecode($_POST['userID']);
  7. $postCount = rawurldecode($_POST['postCount']);
  8. $startPost = rawurldecode($_POST['startPost']);
  9. if ($userID == $user->id)
  10. {
  11. $own_blog = true;
  12. }
  13. if ($user->admin)
  14. {
  15. $own_blog = true;
  16. }
  17. if (isset($_POST['postID']))
  18. {
  19. $posts = get_post(rawurldecode('blog', $_POST['postID']), $db);
  20. }
  21. else
  22. {
  23. $posts = get_blog($userID, $db, $postCount, $startPost);
  24. }
  25. if ($posts)
  26. {
  27. $viewablePosts = 0;
  28. foreach ($posts as $post)
  29. {
  30. $post_id = $post['id'];
  31. $author_id = $post['author_id'];
  32. $author = $userTools->get($author_id);
  33. $date = $post['date_posted'];
  34. $published = $post['published'];
  35. $title = $post['title'];
  36. $tags = $post['tags'];
  37. $post = $post['post'];
  38. $reply_msg = "";
  39. if ($published || $own_blog)
  40. {
  41. $replies = $db->select('comments', "reply_id=? AND service=?", array($post_id, 'blog'), 'count(*) cnt');
  42. $reply_count = $replies['cnt'];
  43. if ($reply_count > 0)
  44. {
  45. $reply_msg = " | <a href='".get_page_url("blog", $CONF)."/".$author->username."/".$post_id."#replies'>Replies:".$reply_count."</a>";
  46. }
  47. ?>
  48. <script>
  49. var converter = new Markdown.getSanitizingConverter();
  50. // Title Conversion
  51. var old_post = $("#title_<?php echo $post_id; ?>").text();
  52. var new_post = converter.makeHtml(old_post);
  53. $("#title_<?php echo $post_id; ?>").html(new_post);
  54. // Post Conversion
  55. var old_post = $("#post_<?php echo $post_id; ?>").text();
  56. var new_post = converter.makeHtml(old_post);
  57. $("#post_<?php echo $post_id; ?>").html(new_post);
  58. </script>
  59. <div class="row">
  60. <div class="col-sm-10 col-sm-offset-1">
  61. <div class="blog-post">
  62. <h2 class="blog-post-title text-center"><a href="<?php echo get_page_url("blog", $CONF); ?>/<?php echo $author->username; ?>/<?php echo $post_id; ?>" id="title_<?php echo $post_id; ?>"><?php echo $title; ?></a></h2>
  63. <p class="blog-post-meta text-center text-muted">
  64. Posted on <?php echo date("F d, Y",strtotime($date)); ?> by <a href="<?php echo get_page_url("home", $CONF); ?>/<?php echo $author->username; ?>"><?php echo $author->username; ?></a><?php echo $reply_msg; ?>
  65. <?php
  66. if ($own_blog)
  67. {
  68. ?>
  69. <br />
  70. <button type="button" class="btn btn-info edit_post" id="<?php echo $post_id; ?>" data-toggle="modal" data-target="#editPost">Edit</button>
  71. <?php
  72. if ($published)
  73. {
  74. ?>
  75. <button type="button" class="btn btn-warning unpublish_post" id="<?php echo $post_id; ?>">Unpublish</button>
  76. <?php
  77. }
  78. else
  79. {
  80. ?>
  81. <button type="button" class="btn btn-success publish_post" id="<?php echo $post_id; ?>">Publish</button>
  82. <?php
  83. }
  84. ?>
  85. <button type="button" class="btn btn-danger delete_post" id="<?php echo $post_id; ?>">Delete</button>
  86. <?php
  87. }
  88. ?>
  89. </p>
  90. <p id="post_<?php echo $post_id; ?>"><?php echo $post; ?></p>
  91. </div>
  92. </div>
  93. </div>
  94. <?php
  95. $viewablePosts++;
  96. }
  97. }
  98. if ($viewablePosts == 0)
  99. {
  100. ?>
  101. <div class="row">
  102. <div class="col-sm-12 text-center">
  103. <h2>There are currently no articles.</h2>
  104. </div>
  105. </div>
  106. <?php
  107. }
  108. }
  109. }
  110. ?>