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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. $published = $post['published'];
  23. $title = $post['title'];
  24. $tags = $post['tags'];
  25. $post = $post['post'];
  26. if ($author_id == $user->id || $user->admin)
  27. {
  28. $own_blog = true;
  29. }
  30. if ($published || $own_blog)
  31. {
  32. set_page_title($title);
  33. ?>
  34. <div class="container">
  35. <?php
  36. if ($own_blog)
  37. {
  38. ?>
  39. <div class="modal fade" id="editPost" tabindex="-1" role="dialog" aria-labelledby="editPostLabel" aria-hidden="true">
  40. <div class="modal-dialog">
  41. <div class="modal-content">
  42. <form class="form" action="##" method="post" id="editPostForm">
  43. <div class="modal-header">
  44. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  45. <h4 class="modal-title" id="editPostLabel">Edit Your Post</h4>
  46. </div>
  47. <div class="modal-body">
  48. <input name="edit_blog_userid" id="edit_blog_userid" type="hidden" value="<?php echo $author_id; ?>" />
  49. <input name="edit_blog_postid" id="edit_blog_postid" type="hidden" />
  50. <div class="row">
  51. <div class="form-group col-sm-12">
  52. <label for="edit_blog_title"><h4>Title</h4></label>
  53. <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" />
  54. </div>
  55. </div>
  56. <div class="row">
  57. <div class="form-group col-sm-12">
  58. <label for="edit_blog_post"><h4>Article</h4></label>
  59. <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>
  60. </div>
  61. </div>
  62. </div>
  63. <div class="modal-footer">
  64. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  65. <button type="button" class="btn btn-primary" id="edit_submit">Save</button>
  66. </div>
  67. </form>
  68. </div>
  69. </div>
  70. </div>
  71. <?php
  72. }
  73. ?>
  74. <div class="blog-main" id="<?php echo $post_id; ?>">
  75. <div class="row">
  76. <div class="col-sm-10 col-sm-offset-1 blog-main">
  77. <div class="blog-post">
  78. <ol class="breadcrumb">
  79. <li><a href="<?php echo get_page_url('blog', $CONF); ?>/<?php echo $author->username; ?>"><?php echo $author->username; ?></a></li>
  80. <li class="active"><a href="#"><?php echo $title; ?></a></li>
  81. </ol>
  82. <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>
  83. <p class="blog-post-meta text-center text-muted">
  84. 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>
  85. <?php
  86. if ($own_blog)
  87. {
  88. ?>
  89. <br />
  90. <button type="button" class="btn btn-info edit_post" id="<?php echo $post_id; ?>" data-toggle="modal" data-target="#editPost">Edit</button>
  91. <?php
  92. if ($published)
  93. {
  94. ?>
  95. <button type="button" class="btn btn-warning unpublish_post" id="<?php echo $post_id; ?>">Unpublish</button>
  96. <?php
  97. }
  98. else
  99. {
  100. ?>
  101. <button type="button" class="btn btn-success publish_post" id="<?php echo $post_id; ?>">Publish</button>
  102. <?php
  103. }
  104. ?>
  105. <button type="button" class="btn btn-danger delete_post" id="<?php echo $post_id; ?>">Delete</button>
  106. <?php
  107. }
  108. ?>
  109. </p>
  110. <p id="post_<?php echo $post_id; ?>"><?php echo $post; ?></p>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <?php
  116. if ($logged_in)
  117. {
  118. ?>
  119. <div class="row">
  120. <div class="col-sm-10 col-sm-offset-1">
  121. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newComment">Add Comment</button>
  122. </div>
  123. </div>
  124. <br />
  125. <div class="modal fade" id="newComment" tabindex="-1" role="dialog" aria-labelledby="newCommentLabel" aria-hidden="true">
  126. <div class="modal-dialog">
  127. <div class="modal-content">
  128. <form class="form" action="##" method="post" id="publishComment">
  129. <div class="modal-header">
  130. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  131. <h4 class="modal-title" id="newCommentLabel">Add a New Comment</h4>
  132. </div>
  133. <div class="modal-body">
  134. <input name="post_id" id="post_id" type="hidden" value="<?php echo $post_id; ?>" />
  135. <div class="row">
  136. <div class="form-group col-sm-12">
  137. <label for="comment_post"><h4>Comment</h4></label>
  138. <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>
  139. </div>
  140. </div>
  141. </div>
  142. <div class="modal-footer">
  143. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  144. <button type="button" class="btn btn-primary" id="comment_submit">Publish</button>
  145. </div>
  146. </form>
  147. </div>
  148. </div>
  149. </div>
  150. <div class="modal fade" id="editComment" tabindex="-1" role="dialog" aria-labelledby="editCommentLabel" aria-hidden="true">
  151. <div class="modal-dialog">
  152. <div class="modal-content">
  153. <form class="form" action="##" method="post" id="editCommentForm">
  154. <div class="modal-header">
  155. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  156. <h4 class="modal-title" id="editCommentLabel">Edit Your Comment</h4>
  157. </div>
  158. <div class="modal-body">
  159. <input name="edit_comment_postid" id="edit_comment_postid" type="hidden" />
  160. <div class="row">
  161. <div class="form-group col-sm-12">
  162. <label for="edit_comment_post"><h4>Comment</h4></label>
  163. <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>
  164. </div>
  165. </div>
  166. </div>
  167. <div class="modal-footer">
  168. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  169. <button type="button" class="btn btn-primary" id="edit_comment_submit">Save</button>
  170. </div>
  171. </form>
  172. </div>
  173. </div>
  174. </div>
  175. <?php
  176. }
  177. ?>
  178. <a name="replies"></a>
  179. <div class="post-comments" id="<?php echo $post_id; ?>"></div>
  180. <script>
  181. var converter = new Markdown.getSanitizingConverter();
  182. // Title Conversion
  183. var old_post = $("#title_<?php echo $post_id; ?>").text();
  184. var new_post = converter.makeHtml(old_post);
  185. $("#title_<?php echo $post_id; ?>").html(new_post);
  186. // Post Conversion
  187. var old_post = $("#post_<?php echo $post_id; ?>").text();
  188. var new_post = converter.makeHtml(old_post);
  189. $("#post_<?php echo $post_id; ?>").html(new_post);
  190. var posts = <?php echo $comments_per_load; ?>;
  191. var start_post = 0;
  192. var view_post_id = <?php echo $post_num; ?>;
  193. loadMoreComments(start_post, posts);
  194. start_post = start_post + posts;
  195. </script>
  196. <?php
  197. }
  198. else
  199. {
  200. set_page_title("Invalid Post");
  201. ?>
  202. <div class="row">
  203. <div class="col-sm-12 text-center">
  204. <h2>That post does not exist</h2>
  205. </div>
  206. </div>
  207. <?php
  208. }
  209. }
  210. else
  211. {
  212. set_page_title("Invalid Post");
  213. ?>
  214. <div class="row">
  215. <div class="col-sm-12 text-center">
  216. <h2>That post does not exist</h2>
  217. </div>
  218. </div>
  219. <?php
  220. }
  221. ?>
  222. </div>
  223. <?php
  224. }
  225. else
  226. {
  227. set_page_title("Invalid Post");
  228. ?>
  229. <div class="row">
  230. <div class="col-sm-12 text-center">
  231. <h2>Invalid Post Number</h2>
  232. </div>
  233. </div>
  234. <?php
  235. }
  236. }
  237. else
  238. {
  239. set_page_title("Invalid Post");
  240. ?>
  241. <div class="row">
  242. <div class="col-sm-12 text-center">
  243. <h2>That post does not exist</h2>
  244. </div>
  245. </div>
  246. <?php
  247. }
  248. include('../templates/'.$CONF['template'].'/footer.php');
  249. ?>