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_image.php 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. /*
  3. * Project Teknik - By Chris Woodward
  4. * Integration of all my services under one roof.
  5. * Maybe awesome?
  6. *
  7. * Single Creation Page
  8. *
  9. */
  10. require_once('../includes/config.php');
  11. include('../templates/'.$CONF['template'].'/header.php');
  12. if (isset($_GET['id']))
  13. {
  14. $desktop_id = $_GET['id'];
  15. $result = $db->select_raw('ricehalla', "INNER JOIN votes ON ricehalla.id=votes.row_id WHERE votes.table_name=? AND ricehalla.id=? GROUP BY votes.row_id ORDER BY TotalPoints DESC", array("ricehalla", $desktop_id), 'ricehalla.url, ricehalla.user_id, ricehalla.id, ricehalla.tags, votes.points, sum(votes.points) TotalPoints, ricehalla.date_added');
  16. if ($result)
  17. {
  18. // Generate Ranking List
  19. $rankResults = $db->select_raw('ricehalla', "INNER JOIN votes ON ricehalla.id=votes.row_id WHERE votes.table_name=? GROUP BY votes.row_id ORDER BY TotalRank DESC, TotalVotes DESC, TotalPoints DESC", array("ricehalla"), 'ricehalla.id, sum(votes.points) as TotalPoints, COUNT(votes.id) as TotalVotes, (sum(votes.points) / COUNT(votes.id)) * abs(sum(votes.points)) as TotalRank');
  20. $rank_list = array();
  21. foreach ($rankResults as $rank_result)
  22. {
  23. if (!is_array($rank_result))
  24. {
  25. $result_list = array($rankResults);
  26. break;
  27. }
  28. array_push($rank_list, $rank_result);
  29. }
  30. $username = $userTools->get($result['user_id'])->username;
  31. $rank = multi_array_search($rank_list, array('id' => $desktop_id))[0] + 1;
  32. $image_src = get_page_url("u", $CONF).'/'.$result['url'];
  33. $user_vote = $db->select('votes', 'table_name=? AND row_id=? AND user_id=? ORDER BY id DESC LIMIT 1', array('ricehalla', $result['id'], $user->id));
  34. $thumb_up = "btn-hover";
  35. $thumb_down = "btn-hover";
  36. if ($user_vote)
  37. {
  38. if ($user_vote['points'] > 0)
  39. {
  40. $thumb_up = "";
  41. }
  42. if ($user_vote['points'] < 0)
  43. {
  44. $thumb_down = "";
  45. }
  46. }
  47. ?>
  48. <div class="container">
  49. <div class="panel panel-primary">
  50. <div class="panel-heading">
  51. <div class="row">
  52. <div class="col-sm-1">Rank</div>
  53. <div class="col-sm-<?php if ($logged_in) { echo '2'; } else { echo '1'; } ?>">Points</div>
  54. <div class="col-sm-2">Owner</div>
  55. <div class="col-sm-2">Date Posted</div>
  56. <div class="col-sm-5">Tags</div>
  57. </div>
  58. </div>
  59. <div class="panel-body">
  60. <div class="row">
  61. <div class="col-sm-1">
  62. <?php echo $rank; ?>
  63. </div>
  64. <div class="col-sm-<?php if ($logged_in) { echo '2'; } else { echo '1'; } ?>">
  65. <div class="row">
  66. <div class="col-sm-2" id="points_<?php echo $result['id']; ?>">
  67. (<?php echo $result['TotalPoints']; ?>)
  68. </div>
  69. <?php
  70. if ($logged_in)
  71. {
  72. ?>
  73. <div class="col-sm-2">
  74. <a href="#" class="btn btn-sm <?php echo $thumb_up; ?> btn-success vote_up" id="vote_up_<?php echo $result['id']; ?>" value="<?php echo $result['id']; ?>"><span class="glyphicon glyphicon-thumbs-up"></span></a>
  75. </div>
  76. <div class="col-sm-2">
  77. <a href="#" class="btn btn-sm <?php echo $thumb_down; ?> btn-danger vote_down" id="vote_down_<?php echo $result['id']; ?>" value="<?php echo $result['id']; ?>"><span class="glyphicon glyphicon-thumbs-down"></span></a>
  78. </div>
  79. <?php
  80. if ($result['user_id'] == $user->id)
  81. {
  82. ?>
  83. <div class="col-sm-2">
  84. <button class="btn btn-sm btn-danger delete_image" id="<?php echo $result['id']; ?>"><span class="glyphicon glyphicon-remove"></span></button>
  85. </div>
  86. <?php
  87. }
  88. }
  89. ?>
  90. </div>
  91. </div>
  92. <div class="col-sm-2">
  93. <?php echo $username; ?>
  94. </div>
  95. <div class="col-sm-2">
  96. <?php echo $result['date_added']; ?>
  97. </div>
  98. <div class="col-sm-5">
  99. <div id="taglist-<?php echo $result['id']; ?>" class="tag-list"></div>
  100. </div>
  101. <script>
  102. $(function() {
  103. var tag_str = "<?php echo $result['tags']; ?>";
  104. if (tag_str != "")
  105. {
  106. var tag_list = tag_str.split(",");
  107. var tags = new Array();
  108. for (var i = 0; i < tag_list.length; i++)
  109. {
  110. tags.push(tag_list[i]);
  111. }
  112. }
  113. $('#taglist-<?php echo $result['id']; ?>').tags({
  114. suggestions:["Windows", "Linux"],
  115. <?php
  116. if (!$logged_in || $result['user_id'] != $user->id)
  117. {
  118. ?>
  119. readOnly: true,
  120. <?php
  121. }
  122. ?>
  123. tagData: tags,
  124. tagSize: "sm",
  125. tagClass: "btn-primary",
  126. afterAddingTag: function(tag){
  127. var current_tags = $('#taglist-<?php echo $result['id']; ?>').tags().getTags();
  128. var url = "../edit_tags.php";
  129. var data = "id="+encodeURIComponent(<?php echo $result['id']; ?>)+"&tags="+encodeURIComponent(current_tags);
  130. $.ajax({
  131. type: "POST",
  132. url: url,
  133. data: data
  134. });
  135. },
  136. afterDeletingTag: function(tag){
  137. var current_tags = $('#taglist-<?php echo $result['id']; ?>').tags().getTags();
  138. var url = "../edit_tags.php";
  139. var data = "id="+encodeURIComponent(<?php echo $result['id']; ?>)+"&tags="+encodeURIComponent(current_tags);
  140. $.ajax({
  141. type: "POST",
  142. url: url,
  143. data: data
  144. });
  145. }
  146. });
  147. });
  148. </script>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. <div class="container">
  154. <div class="row text-center">
  155. <div class="col-sm-12 view_image" style="overflow: hidden;">
  156. <a href="<?php echo get_page_url("u", $CONF).'/'.$result['url']; ?>" value="<?php echo $image_src; ?>" target="_blank">
  157. <img src="<?php echo $image_src; ?>" class="img-responsive img-thumbnail" alt="">
  158. </a>
  159. </div>
  160. </div>
  161. </div>
  162. <br />
  163. <?php
  164. include('../templates/'.$CONF['template'].'/footer.php');
  165. set_page_title($username . "'s Creation - Teknik's Ricehalla");
  166. }
  167. else
  168. {
  169. set_page_title("Teknik's Ricehalla");
  170. ?>
  171. <div class="container">
  172. <div class="row">
  173. <div class="col-sm-12 text-center">
  174. <h2>The specified creation does not exist.</h2>
  175. </div>
  176. </div>
  177. </div>
  178. <?php
  179. }
  180. }
  181. else
  182. {
  183. redirect(get_page_url("home", $CONF));
  184. }
  185. ?>