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 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. $title = $post['title'];
  34. $tags = $post['tags'];
  35. $post = $post['post'];
  36. $reply_msg = "";
  37. $replies = $db->select('comments', "reply_id=? AND service=?", array($post_id, 'blog'), 'count(*) cnt');
  38. $reply_count = $replies['cnt'];
  39. if ($reply_count > 0)
  40. {
  41. $reply_msg = " | <a href='".get_page_url("blog", $CONF)."/".$author->username."/".$post_id."#replies'>Replies:".$reply_count."</a>";
  42. }
  43. ?>
  44. <script>
  45. var converter = new Markdown.getSanitizingConverter();
  46. // Title Conversion
  47. var old_post = $("#title_<?php echo $post_id; ?>").text();
  48. var new_post = converter.makeHtml(old_post);
  49. $("#title_<?php echo $post_id; ?>").html(new_post);
  50. // Post Conversion
  51. var old_post = $("#post_<?php echo $post_id; ?>").text();
  52. var new_post = converter.makeHtml(old_post);
  53. $("#post_<?php echo $post_id; ?>").html(new_post);
  54. </script>
  55. <div class="row">
  56. <div class="col-sm-10 col-sm-offset-1 blog-main">
  57. <div class="blog-post">
  58. <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>
  59. <p class="blog-post-meta text-center text-muted">
  60. 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; ?>
  61. <?php
  62. if ($own_blog)
  63. {
  64. ?>
  65. <br />
  66. <button type="button" class="btn btn-info edit_post" id="<?php echo $post_id; ?>" data-toggle="modal" data-target="#editPost">Edit</button>
  67. <button type="button" class="btn btn-danger delete_post" id="<?php echo $post_id; ?>">Delete</button>
  68. <?php
  69. }
  70. ?>
  71. </p>
  72. <p id="post_<?php echo $post_id; ?>"><?php echo $post; ?></p>
  73. </div>
  74. </div>
  75. </div>
  76. <?php
  77. }
  78. }
  79. }
  80. ?>