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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. <ol class="breadcrumb">
  76. <li><a href="<?php echo get_page_url('blog', $CONF); ?>/<?php echo $author->username; ?>"><?php echo $author->username; ?></a></li>
  77. <li class="active"><a href="#"><?php echo $title; ?></a></li>
  78. </ol>
  79. <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>
  80. <p class="blog-post-meta text-center text-muted">
  81. 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>
  82. <?php
  83. if ($own_blog)
  84. {
  85. ?>
  86. <br />
  87. <button type="button" class="btn btn-info edit_post" id="<?php echo $post_id; ?>" data-toggle="modal" data-target="#editPost">Edit</button>
  88. <button type="button" class="btn btn-danger delete_post" id="<?php echo $post_id; ?>">Delete</button>
  89. <?php
  90. }
  91. ?>
  92. </p>
  93. <p id="post_<?php echo $post_id; ?>"><?php echo $post; ?></p>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. <?php
  99. if ($logged_in)
  100. {
  101. ?>
  102. <div class="row">
  103. <div class="col-sm-10 col-sm-offset-1">
  104. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newComment">Add Comment</button>
  105. </div>
  106. </div>
  107. <br />
  108. <div class="modal fade" id="newComment" tabindex="-1" role="dialog" aria-labelledby="newCommentLabel" aria-hidden="true">
  109. <div class="modal-dialog">
  110. <div class="modal-content">
  111. <form class="form" action="##" method="post" id="publishComment">
  112. <div class="modal-header">
  113. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  114. <h4 class="modal-title" id="newCommentLabel">Add a New Comment</h4>
  115. </div>
  116. <div class="modal-body">
  117. <input name="post_id" id="post_id" type="hidden" value="<?php echo $post_id; ?>" />
  118. <div class="row">
  119. <div class="form-group col-sm-12">
  120. <label for="comment_post"><h4>Comment</h4></label>
  121. <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>
  122. </div>
  123. </div>
  124. </div>
  125. <div class="modal-footer">
  126. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  127. <button type="button" class="btn btn-primary" id="comment_submit">Publish</button>
  128. </div>
  129. </form>
  130. </div>
  131. </div>
  132. </div>
  133. <div class="modal fade" id="editComment" tabindex="-1" role="dialog" aria-labelledby="editCommentLabel" aria-hidden="true">
  134. <div class="modal-dialog">
  135. <div class="modal-content">
  136. <form class="form" action="##" method="post" id="editCommentForm">
  137. <div class="modal-header">
  138. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  139. <h4 class="modal-title" id="editCommentLabel">Edit Your Comment</h4>
  140. </div>
  141. <div class="modal-body">
  142. <input name="edit_comment_postid" id="edit_comment_postid" type="hidden" />
  143. <div class="row">
  144. <div class="form-group col-sm-12">
  145. <label for="edit_comment_post"><h4>Comment</h4></label>
  146. <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>
  147. </div>
  148. </div>
  149. </div>
  150. <div class="modal-footer">
  151. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  152. <button type="button" class="btn btn-primary" id="edit_comment_submit">Save</button>
  153. </div>
  154. </form>
  155. </div>
  156. </div>
  157. </div>
  158. <?php
  159. }
  160. ?>
  161. <a name="replies"></a>
  162. <div class="post-comments" id="<?php echo $post_id; ?>"></div>
  163. <script>
  164. var converter = new Markdown.getSanitizingConverter();
  165. // Title Conversion
  166. var old_post = $("#title_<?php echo $post_id; ?>").text();
  167. var new_post = converter.makeHtml(old_post);
  168. $("#title_<?php echo $post_id; ?>").html(new_post);
  169. // Post Conversion
  170. var old_post = $("#post_<?php echo $post_id; ?>").text();
  171. var new_post = converter.makeHtml(old_post);
  172. $("#post_<?php echo $post_id; ?>").html(new_post);
  173. var posts = <?php echo $comments_per_load; ?>;
  174. var start_post = 0;
  175. var view_post_id = <?php echo $post_num; ?>;
  176. loadMoreComments(start_post, posts);
  177. start_post = start_post + posts;
  178. </script>
  179. <?php
  180. }
  181. else
  182. {
  183. set_page_title("Invalid Post");
  184. ?>
  185. <div class="row">
  186. <div class="col-sm-12 text-center">
  187. <h2>That post does not exist</h2>
  188. </div>
  189. </div>
  190. <?php
  191. }
  192. ?>
  193. </div>
  194. <?php
  195. }
  196. else
  197. {
  198. set_page_title("Invalid Post");
  199. ?>
  200. <div class="row">
  201. <div class="col-sm-12 text-center">
  202. <h2>Invalid Post Number</h2>
  203. </div>
  204. </div>
  205. <?php
  206. }
  207. }
  208. else
  209. {
  210. set_page_title("Invalid Post");
  211. ?>
  212. <div class="row">
  213. <div class="col-sm-12 text-center">
  214. <h2>That post does not exist</h2>
  215. </div>
  216. </div>
  217. <?php
  218. }
  219. include('../templates/'.$CONF['template'].'/footer.php');
  220. ?>