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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <?php
  2. require_once('../includes/config.php');
  3. include('../templates/'.$CONF['template'].'/header.php');
  4. $post_num = 0;
  5. $comments_per_load = 10;
  6. $error = "";
  7. if (isset($_GET['post']))
  8. {
  9. if (is_numeric($_GET['post']))
  10. {
  11. $post_num = (int) rawurldecode($_GET['post']);
  12. $posts = get_post('podcast', $post_num, $db);
  13. if ($posts)
  14. {
  15. $post = $posts[0];
  16. $post_id = $post['id'];
  17. $date = $post['date_posted'];
  18. $title = $post['title'];
  19. $tags = $post['tags'];
  20. $file = $post['file_name'];
  21. $files = explode(',', $file);
  22. $post = $post['description'];
  23. set_page_title($title);
  24. ?>
  25. <div class="container">
  26. <?php
  27. if ($user->admin)
  28. {
  29. ?>
  30. <div class="modal fade" id="editPodcast" tabindex="-1" role="dialog" aria-labelledby="editPodcastLabel" aria-hidden="true">
  31. <div class="modal-dialog">
  32. <div class="modal-content">
  33. <form class="form" action="##" method="post" id="editPodcastForm">
  34. <div class="modal-header">
  35. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  36. <h4 class="modal-title" id="editPodcastLabel">Edit Your Post</h4>
  37. </div>
  38. <div class="modal-body">
  39. <input name="edit_podcast_postid" id="edit_podcast_postid" type="hidden" />
  40. <div class="row">
  41. <div class="form-group col-sm-12">
  42. <label for="edit_podcast_title"><h4>Title</h4></label>
  43. <input class="form-control" name="edit_podcast_title" id="edit_podcast_title" placeholder="Awesome Podcast Title" title="enter a title for the podcast." type="text" />
  44. </div>
  45. </div>
  46. <div class="row">
  47. <div class="form-group col-sm-12">
  48. <label for="edit_podcast_post"><h4>Podcast Description</h4></label>
  49. <textarea class="form-control wmd-input" name="edit_podcast_post" id="edit_podcast_post" placeholder="We talked about awesome stuff." title="enter what the podcast was about." data-provide="markdown" rows="10"></textarea>
  50. </div>
  51. </div>
  52. <div class="row">
  53. <div class="form-group col-sm-12">
  54. <label for="uploadPodcast"><h4>Upload Podcast</h4></label>
  55. <input id="edit_uploadPodcast" name="file" type="file" placeholder="podcast.ogg" title="select the podcast file." />
  56. </div>
  57. </div>
  58. <div class="row">
  59. <div class="form-group col-sm-12" id="edit_uploadedPodcasts"></div>
  60. <input name="edit_podcast_file" id="edit_podcast_file" type="hidden" />
  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="podcast-main" id="<?php echo $post_id; ?>">
  75. <div class="row">
  76. <div class="col-sm-10 col-sm-offset-1 podcast-main">
  77. <div class="podcast-post">
  78. <h2 class="podcast-post-title text-center"><a href="<?php echo get_page_url("podcast", $CONF); ?>/<?php echo $post_id; ?>" id="title_<?php echo $post_id; ?>"><?php echo $title; ?></a></h2>
  79. <p class="podcast-post-meta text-center text-muted">
  80. Posted on <?php echo date("F d, Y",strtotime($date)); ?>
  81. <?php
  82. if ($user->admin)
  83. {
  84. ?>
  85. <br />
  86. <button type="button" class="btn btn-info edit_post" id="<?php echo $post_id; ?>" data-toggle="modal" data-target="#editPodcast">Edit</button>
  87. <button type="button" class="btn btn-danger delete_post" id="<?php echo $post_id; ?>">Delete</button>
  88. <?php
  89. }
  90. ?>
  91. </p>
  92. <div class="text-center">
  93. <audio preload="none" controls>
  94. <?php
  95. foreach ($files as $filename)
  96. {
  97. $file_path = get_page_url("podcast", $CONF).'/Podcasts/'.$title.'/'.$filename;
  98. $direct_path = $CONF['podcast_dir'].$title.'/'.$filename;
  99. if (file_exists($direct_path))
  100. {
  101. $file_type = mime_content_type($direct_path);
  102. ?>
  103. <source src="<?php echo $file_path; ?>" type="<?php echo $file_type; ?>" />
  104. <?php
  105. }
  106. }
  107. ?>
  108. </audio>
  109. </div>
  110. <br />
  111. <p id="post_<?php echo $post_id; ?>"><?php echo $post; ?></p>
  112. <?php
  113. foreach ($files as $filename)
  114. {
  115. $file_path = get_page_url("podcast", $CONF).'/Podcasts/'.$title.'/'.$filename;
  116. $direct_path = $CONF['podcast_dir'].$title.'/'.$filename;
  117. if (file_exists($direct_path))
  118. {
  119. $file_type = mime_content_type($direct_path);
  120. ?>
  121. <div class="row text-center">
  122. <a href="<?php echo $file_path; ?>">Direct Download - <?php echo explode('/', $file_type)[1]; ?></a>
  123. </div>
  124. <?php
  125. }
  126. }
  127. ?>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <?php
  133. if ($logged_in)
  134. {
  135. ?>
  136. <div class="row">
  137. <div class="col-sm-10 col-sm-offset-1">
  138. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newComment">Add Comment</button>
  139. </div>
  140. </div>
  141. <br />
  142. <div class="modal fade" id="newComment" tabindex="-1" role="dialog" aria-labelledby="newCommentLabel" aria-hidden="true">
  143. <div class="modal-dialog">
  144. <div class="modal-content">
  145. <form class="form" action="##" method="post" id="publishComment">
  146. <div class="modal-header">
  147. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  148. <h4 class="modal-title" id="newCommentLabel">Add a New Comment</h4>
  149. </div>
  150. <div class="modal-body">
  151. <input name="post_id" id="post_id" type="hidden" value="<?php echo $post_id; ?>" />
  152. <div class="row">
  153. <div class="form-group col-sm-12">
  154. <label for="comment_post"><h4>Comment</h4></label>
  155. <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>
  156. </div>
  157. </div>
  158. </div>
  159. <div class="modal-footer">
  160. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  161. <button type="button" class="btn btn-primary" id="comment_submit">Publish</button>
  162. </div>
  163. </form>
  164. </div>
  165. </div>
  166. </div>
  167. <div class="modal fade" id="editComment" tabindex="-1" role="dialog" aria-labelledby="editCommentLabel" aria-hidden="true">
  168. <div class="modal-dialog">
  169. <div class="modal-content">
  170. <form class="form" action="##" method="post" id="editCommentForm">
  171. <div class="modal-header">
  172. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  173. <h4 class="modal-title" id="editCommentLabel">Edit Your Comment</h4>
  174. </div>
  175. <div class="modal-body">
  176. <input name="edit_comment_postid" id="edit_comment_postid" type="hidden" />
  177. <div class="row">
  178. <div class="form-group col-sm-12">
  179. <label for="edit_comment_post"><h4>Comment</h4></label>
  180. <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>
  181. </div>
  182. </div>
  183. </div>
  184. <div class="modal-footer">
  185. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  186. <button type="button" class="btn btn-primary" id="edit_comment_submit">Save</button>
  187. </div>
  188. </form>
  189. </div>
  190. </div>
  191. </div>
  192. <?php
  193. }
  194. ?>
  195. <a name="replies"></a>
  196. <div class="post-comments" id="<?php echo $post_id; ?>"></div>
  197. <script>
  198. $( function()
  199. {
  200. linkAudioPlayer('audio');
  201. });
  202. var converter = new Markdown.getSanitizingConverter();
  203. var old_post = $("#post_<?php echo $post_id; ?>").text();
  204. var new_post = converter.makeHtml(old_post);
  205. $("#post_<?php echo $post_id; ?>").html(new_post);
  206. var posts = <?php echo $comments_per_load; ?>;
  207. var start_post = 0;
  208. var view_post_id = <?php echo $post_num; ?>;
  209. loadMoreComments(start_post, posts);
  210. start_post = start_post + posts;
  211. </script>
  212. <?php
  213. }
  214. else
  215. {
  216. set_page_title("Invalid Podcast");
  217. ?>
  218. <div class="row">
  219. <div class="col-sm-12 text-center">
  220. <h2>That podcast does not exist</h2>
  221. </div>
  222. </div>
  223. <?php
  224. }
  225. ?>
  226. </div>
  227. <?php
  228. }
  229. else
  230. {
  231. set_page_title("Invalid Podcast");
  232. ?>
  233. <div class="row">
  234. <div class="col-sm-12 text-center">
  235. <h2>Invalid Podcast Number</h2>
  236. </div>
  237. </div>
  238. <?php
  239. }
  240. }
  241. else
  242. {
  243. set_page_title("Invalid Podcast");
  244. ?>
  245. <div class="row">
  246. <div class="col-sm-12 text-center">
  247. <h2>That podcast does not exist</h2>
  248. </div>
  249. </div>
  250. <?php
  251. }
  252. include('../templates/'.$CONF['template'].'/footer.php');
  253. ?>