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.

main.php 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. $own_blog = false;
  3. $blog_id = 0;
  4. $blog_author = "";
  5. $blog_title = $CONF['blog_title'];
  6. $blog_desc = $CONF['blog_desc'];
  7. $title_bar = $CONF['blog_title'];
  8. $posts_per_load = 10;
  9. $error = "";
  10. if (isset($_GET['author']))
  11. {
  12. if ($userTools->checkUsernameExists($_GET['author']))
  13. {
  14. $blog_user = $userTools->getUser($_GET['author']);
  15. $blog_id = $blog_user->id;
  16. $blog_author = $blog_user->username;
  17. $blog_title = $blog_user->blog_title;
  18. $blog_desc = $blog_user->blog_desc;
  19. if ($blog_id == $user->id)
  20. {
  21. $own_blog = true;
  22. }
  23. if (empty($blog_title))
  24. {
  25. $title_bar = safe($_GET['author'])."'s Blog";
  26. }
  27. else
  28. {
  29. $title_bar = $blog_title;
  30. }
  31. }
  32. else
  33. {
  34. $blog_id = -1;
  35. $blog_title = "";
  36. $blog_desc = "";
  37. $error = "That user does not exist!";
  38. }
  39. }
  40. $blog_posts = $db->select('blog', "user_id=?", array($blog_id));
  41. if (!$blog_posts && $blog_id >= 0)
  42. {
  43. $error = "There are currently no articles.";
  44. }
  45. if ($user->admin)
  46. {
  47. $own_blog = true;
  48. }
  49. set_page_title($title_bar);
  50. ?>
  51. <div class="container">
  52. <?php
  53. if ($blog_id >= 0)
  54. {
  55. ?>
  56. <div class="row">
  57. <div class="col-sm-12 blog-heading">
  58. <h1 class="blog-title text-center"><?php echo $blog_title; ?></h1>
  59. <p class="lead blog-description text-center text-muted"><?php echo $blog_desc; ?></p>
  60. </div>
  61. </div>
  62. <div class="row">
  63. <div class="col-sm-12 text-center">
  64. <p>
  65. <a href="<?php echo get_page_url('rss', $CONF).'/blog/'.$blog_author; ?>"><i class="fa fa-rss fa-2x fa-border"></i></a>
  66. </p>
  67. </div>
  68. </div>
  69. <?php
  70. }
  71. if ($own_blog)
  72. {
  73. ?>
  74. <div class="row">
  75. <div class="col-sm-12 text-center">
  76. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newPost">Create Post</button>
  77. </div>
  78. </div>
  79. <div class="modal fade" id="newPost" tabindex="-1" role="dialog" aria-labelledby="newPostLabel" aria-hidden="true">
  80. <div class="modal-dialog">
  81. <div class="modal-content">
  82. <form class="form" action="##" method="post" id="publishPost">
  83. <div class="modal-header">
  84. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  85. <h4 class="modal-title" id="newPostLabel">Create a New Post</h4>
  86. </div>
  87. <div class="modal-body">
  88. <input name="blog_userid" id="blog_userid" type="hidden" value="<?php echo $blog_id; ?>" />
  89. <div class="row">
  90. <div class="form-group col-sm-12">
  91. <label for="blog_title"><h4>Title</h4></label>
  92. <input class="form-control" name="blog_title" id="blog_title" placeholder="generic click bait" title="enter a title for your post." type="text" />
  93. </div>
  94. </div>
  95. <div class="row">
  96. <div class="form-group col-sm-12">
  97. <label for="blog_post"><h4>Article</h4></label>
  98. <textarea class="form-control wmd-input" name="blog_post" id="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>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="modal-footer">
  103. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  104. <button type="button" class="btn btn-primary" id="blog_submit">Create</button>
  105. </div>
  106. </form>
  107. </div>
  108. </div>
  109. </div>
  110. <div class="modal fade" id="editPost" tabindex="-1" role="dialog" aria-labelledby="editPostLabel" aria-hidden="true">
  111. <div class="modal-dialog">
  112. <div class="modal-content">
  113. <form class="form" action="##" method="post" id="editPostForm">
  114. <div class="modal-header">
  115. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Cancel</span></button>
  116. <h4 class="modal-title" id="editPostLabel">Edit Your Post</h4>
  117. </div>
  118. <div class="modal-body">
  119. <input name="edit_blog_userid" id="edit_blog_userid" type="hidden" value="<?php echo $blog_id; ?>" />
  120. <input name="edit_blog_postid" id="edit_blog_postid" type="hidden" />
  121. <div class="row">
  122. <div class="form-group col-sm-12">
  123. <label for="edit_blog_title"><h4>Title</h4></label>
  124. <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" />
  125. </div>
  126. </div>
  127. <div class="row">
  128. <div class="form-group col-sm-12">
  129. <label for="edit_blog_post"><h4>Article</h4></label>
  130. <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>
  131. </div>
  132. </div>
  133. </div>
  134. <div class="modal-footer">
  135. <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
  136. <button type="button" class="btn btn-primary" id="edit_submit">Save</button>
  137. </div>
  138. </form>
  139. </div>
  140. </div>
  141. </div>
  142. <?php
  143. }
  144. if (empty($error))
  145. {
  146. ?>
  147. <div class="blog-main" id="<?php echo $blog_id; ?>"></div>
  148. <script>
  149. var posts = <?php echo $posts_per_load; ?>;
  150. var start_post = 0;
  151. loadMorePosts(start_post, posts);
  152. start_post = start_post + posts;
  153. </script>
  154. <?php
  155. }
  156. else
  157. {
  158. ?>
  159. <div class="row">
  160. <div class="col-sm-12 text-center">
  161. <h2><?php echo $error; ?></h2>
  162. </div>
  163. </div>
  164. <?php
  165. }
  166. ?>
  167. </div>