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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. foreach ($posts as $post)
  28. {
  29. $post_id = $post['id'];
  30. $author_id = $post['author_id'];
  31. $author = $userTools->get($author_id);
  32. $date = $post['date_posted'];
  33. $published = $post['published'];
  34. $title = $post['title'];
  35. $tags = $post['tags'];
  36. $post = $post['post'];
  37. $reply_msg = "";
  38. if ($published || $own_blog)
  39. {
  40. $replies = $db->select('comments', "reply_id=? AND service=?", array($post_id, 'blog'), 'count(*) cnt');
  41. $reply_count = $replies['cnt'];
  42. if ($reply_count > 0)
  43. {
  44. $reply_msg = " | <a href='".get_page_url("blog", $CONF)."/".$author->username."/".$post_id."#replies'>Replies:".$reply_count."</a>";
  45. }
  46. ?>
  47. <script>
  48. var converter = new Markdown.getSanitizingConverter();
  49. // Title Conversion
  50. var old_post = $("#title_<?php echo $post_id; ?>").text();
  51. var new_post = converter.makeHtml(old_post);
  52. $("#title_<?php echo $post_id; ?>").html(new_post);
  53. // Post Conversion
  54. var old_post = $("#post_<?php echo $post_id; ?>").text();
  55. var new_post = converter.makeHtml(old_post);
  56. $("#post_<?php echo $post_id; ?>").html(new_post);
  57. </script>
  58. <div class="row">
  59. <div class="col-sm-10 col-sm-offset-1">
  60. <div class="blog-post">
  61. <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>
  62. <p class="blog-post-meta text-center text-muted">
  63. 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; ?>
  64. <?php
  65. if ($own_blog)
  66. {
  67. ?>
  68. <br />
  69. <button type="button" class="btn btn-info edit_post" id="<?php echo $post_id; ?>" data-toggle="modal" data-target="#editPost">Edit</button>
  70. <?php
  71. if ($published)
  72. {
  73. ?>
  74. <button type="button" class="btn btn-warning unpublish_post" id="<?php echo $post_id; ?>">Unpublish</button>
  75. <?php
  76. }
  77. else
  78. {
  79. ?>
  80. <button type="button" class="btn btn-success publish_post" id="<?php echo $post_id; ?>">Publish</button>
  81. <?php
  82. }
  83. ?>
  84. <button type="button" class="btn btn-danger delete_post" id="<?php echo $post_id; ?>">Delete</button>
  85. <?php
  86. }
  87. ?>
  88. </p>
  89. <p id="post_<?php echo $post_id; ?>"><?php echo $post; ?></p>
  90. </div>
  91. </div>
  92. </div>
  93. <?php
  94. }
  95. }
  96. }
  97. }
  98. ?>