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.

view_post.php 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. require_once('../includes/config.php');
  3. include('../templates/'.$CONF['template'].'/header.php');
  4. $own_blog = false;
  5. $author_id = 0;
  6. $post_num = 0;
  7. $comments_per_load = 10;
  8. $error = "";
  9. if (isset($_GET['post']))
  10. {
  11. if (is_numeric($_GET['post']))
  12. {
  13. $post_num = (int) rawurldecode($_GET['post']);
  14. $posts = get_post('blog', $post_num, $db);
  15. if ($posts)
  16. {
  17. $post = $posts[0];
  18. $post_id = $post['id'];
  19. $author_id = $post['author_id'];
  20. $author = $userTools->get($author_id);
  21. $date = $post['date_posted'];
  22. $title = $post['title'];
  23. $tags = $post['tags'];
  24. $post = $post['post'];
  25. if ($author_id == $user->id || $user->admin)
  26. {
  27. $own_blog = true;
  28. }
  29. set_page_title($title);
  30. ?>
  31. <div class="container">
  32. <?php
  33. if ($own_blog)
  34. {
  35. ?>
  36. <div class="modal fade" id="editPost" tabindex="-1" role="dialog" aria-labelledby="editPostLabel" aria-hidden="true">
  37. <div class="modal-dialog">
  38. <div class="modal-content">
  39. <form class="form" action="##" method="post" id="editPostForm">
  40. <div class="modal-header">
  41. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  42. <h4 class="modal-title" id="editPostLabel">Edit Your Post</h4>
  43. </div>
  44. <div class="modal-body">
  45. <input name="edit_blog_userid" id="edit_blog_userid" type="hidden" value="<?php echo $author_id; ?>" />
  46. <input name="edit_blog_postid" id="edit_blog_postid" type="hidden" />
  47. <div class="row">
  48. <div class="form-group col-sm-12">
  49. <label for="edit_blog_title"><h4>Title</h4></label>
  50. <input class="form-control" name="edit_blog_title" id="edit_blog_title" placeholder="generic click bait" title="enter a title for your post." type="text" />
  51. </div>
  52. </div>
  53. <div class="row">
  54. <div class="form-group col-sm-12">
  55. <label for="edit_blog_post"><h4>Article</h4></label>
  56. <textarea class="form-control" name="edit_blog_post" id="edit_blog_post" placeholder="I ate a burger today." title="enter any information you want to share with the world." data-provide="markdown" rows="10"></textarea>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="modal-footer">
  61. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  62. <button type="button" class="btn btn-primary" id="edit_submit">Save</button>
  63. </div>
  64. </form>
  65. </div>
  66. </div>
  67. </div>
  68. <?php
  69. }
  70. ?>
  71. <div class="blog-main" id="<?php echo $post_id; ?>">
  72. <div class="row">
  73. <div class="col-sm-10 col-sm-offset-1 blog-main">
  74. <div class="blog-post">
  75. <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>
  76. <p class="blog-post-meta text-center text-muted">
  77. 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>
  78. <?php
  79. if ($own_blog)
  80. {
  81. ?>
  82. <br />
  83. <button type="button" class="btn btn-info edit_post" id="<?php echo $post_id; ?>" data-toggle="modal" data-target="#editPost">Edit</button>
  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. </div>
  94. <?php
  95. if ($logged_in)
  96. {
  97. ?>
  98. <div class="row">
  99. <div class="col-sm-10 col-sm-offset-1">
  100. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newComment">Add Comment</button>
  101. </div>
  102. </div>
  103. <br />
  104. <div class="modal fade" id="newComment" tabindex="-1" role="dialog" aria-labelledby="newCommentLabel" aria-hidden="true">
  105. <div class="modal-dialog">
  106. <div class="modal-content">
  107. <form class="form" action="##" method="post" id="publishComment">
  108. <div class="modal-header">
  109. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  110. <h4 class="modal-title" id="newCommentLabel">Add a New Comment</h4>
  111. </div>
  112. <div class="modal-body">
  113. <input name="post_id" id="post_id" type="hidden" value="<?php echo $post_id; ?>" />
  114. <div class="row">
  115. <div class="form-group col-sm-12">
  116. <label for="comment_post"><h4>Comment</h4></label>
  117. <textarea class="form-control wmd-input" name="comment_post" id="comment_post" placeholder="Nice post!" title="enter what you think about the post." data-provide="markdown" rows="10"></textarea>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="modal-footer">
  122. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  123. <button type="button" class="btn btn-primary" id="comment_submit">Publish</button>
  124. </div>
  125. </form>
  126. </div>
  127. </div>
  128. </div>
  129. <div class="modal fade" id="editComment" tabindex="-1" role="dialog" aria-labelledby="editCommentLabel" aria-hidden="true">
  130. <div class="modal-dialog">
  131. <div class="modal-content">
  132. <form class="form" action="##" method="post" id="editCommentForm">
  133. <div class="modal-header">
  134. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  135. <h4 class="modal-title" id="editCommentLabel">Edit Your Comment</h4>
  136. </div>
  137. <div class="modal-body">
  138. <input name="edit_comment_postid" id="edit_comment_postid" type="hidden" />
  139. <div class="row">
  140. <div class="form-group col-sm-12">
  141. <label for="edit_comment_post"><h4>Comment</h4></label>
  142. <textarea class="form-control" name="edit_comment_post" id="edit_comment_post" placeholder="What an interesting article!" title="enter what you thought about the article." data-provide="markdown" rows="10"></textarea>
  143. </div>
  144. </div>
  145. </div>
  146. <div class="modal-footer">
  147. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  148. <button type="button" class="btn btn-primary" id="edit_comment_submit">Save</button>
  149. </div>
  150. </form>
  151. </div>
  152. </div>
  153. </div>
  154. <?php
  155. }
  156. ?>
  157. <a name="replies">
  158. <div class="post-comments" id="<?php echo $post_id; ?>"></div>
  159. <script>
  160. var converter = new Markdown.getSanitizingConverter();
  161. // Title Conversion
  162. var old_post = $("#title_<?php echo $post_id; ?>").text();
  163. var new_post = converter.makeHtml(old_post);
  164. $("#title_<?php echo $post_id; ?>").html(new_post);
  165. // Post Conversion
  166. var old_post = $("#post_<?php echo $post_id; ?>").text();
  167. var new_post = converter.makeHtml(old_post);
  168. $("#post_<?php echo $post_id; ?>").html(new_post);
  169. var posts = <?php echo $comments_per_load; ?>;
  170. var start_post = 0;
  171. var view_post_id = <?php echo $post_num; ?>;
  172. loadMoreComments(start_post, posts);
  173. start_post = start_post + posts;
  174. </script>
  175. <?php
  176. }
  177. else
  178. {
  179. set_page_title("Invalid Post");
  180. ?>
  181. <div class="row">
  182. <div class="col-sm-12 text-center">
  183. <h2>That post does not exist</h2>
  184. </div>
  185. </div>
  186. <?php
  187. }
  188. ?>
  189. </div>
  190. <?php
  191. }
  192. else
  193. {
  194. set_page_title("Invalid Post");
  195. ?>
  196. <div class="row">
  197. <div class="col-sm-12 text-center">
  198. <h2>Invalid Post Number</h2>
  199. </div>
  200. </div>
  201. <?php
  202. }
  203. }
  204. else
  205. {
  206. set_page_title("Invalid Post");
  207. ?>
  208. <div class="row">
  209. <div class="col-sm-12 text-center">
  210. <h2>That post does not exist</h2>
  211. </div>
  212. </div>
  213. <?php
  214. }
  215. include('../templates/'.$CONF['template'].'/footer.php');
  216. ?>