Advertisement
Guest User

Untitled

a guest
May 28th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.61 KB | None | 0 0
  1. <?
  2.  
  3. $con = mysqli_connect("localhost","username","password","database");
  4.  
  5. if (!$con)
  6. {
  7. die('Could not connect: ' . mysqli_connect_error());
  8. }
  9.  
  10.  
  11. $query = "SELECT * FROM mainfeed ORDER BY timestamp DESC LIMIT 0 , 1000";
  12.  
  13. $comments = mysqli_query($con, $query);
  14.  
  15. echo "<h1>Recent Posts</h1><br><br><hr>";
  16.  
  17. while($row = mysqli_fetch_array($comments, MYSQLI_ASSOC))
  18. {
  19. $comment = $row['comment'];
  20. $timestamp = $row['timestamp'];
  21. $file = $row['file'];
  22. $info = pathinfo($file);
  23. $info['extension'];
  24. $comment = htmlspecialchars($row['comment'],ENT_QUOTES);
  25. $ytlink = $row['ytlink'];
  26. $tag = $row['tag'];
  27. $tag2 = $row['tag2'];
  28. $tag3 = $row['tag3'];
  29. $handle = $row['handle'];
  30. $score = $row['score'];
  31. $id = $row['id'];
  32.  
  33. $ytarray=explode("/", $ytlink);
  34. $ytendstring=end($ytarray);
  35. $ytendarray=explode("?v=", $ytendstring);
  36. $ytendstring=end($ytendarray);
  37. $ytendarray=explode("&", $ytendstring);
  38. $ytcode=$ytendarray[0];
  39.  
  40. $display = Array('jpg', 'jpeg', 'png', 'PNG', 'gif');
  41. $vid = Array('MOV', 'mov', 'mp4');
  42.  
  43.  
  44. if($tag != ''){
  45. $tagdisp = "<br><a href='/$tag' class='posttag'>$tag</a>";
  46.  
  47. }
  48.  
  49. elseif($tag==''){
  50. $tagdisp="";
  51.  
  52. }
  53.  
  54. if($tag2 != ''){
  55. $tagdisp2 = "<a href='/$tag2' class='posttag'>$tag2</a>";
  56.  
  57. }
  58.  
  59. elseif($tag2==''){
  60. $tagdisp2="";
  61.  
  62. }
  63.  
  64. if($tag3 != ''){
  65. $tagdisp3 = "<a href='/$tag3' class='posttag'>$tag3</a>";
  66.  
  67. }
  68.  
  69. elseif($tag3==''){
  70. $tagdisp3="";
  71.  
  72. }
  73.  
  74. if($tag != 'explicit' && $tag2 != 'explicit' && $tag3 != 'explicit'){
  75.  
  76. if ($file != NULL) {
  77.  
  78. if (in_array($info['extension'], $display)){
  79.  
  80. echo " <div class='card'>
  81. <h3>Handle: $handle</h3><br />
  82. <p>$comment</p><br /><br />
  83. <a href='$file'><img src='$file' style='width:70%; margin-left:15%; margin-right:15%; margin-top:5px; border-style:none;'></a><br>
  84. <p>Post #$id</p>
  85. <p id='scorecount-$id'>Score: $score</p><br>
  86. <button onclick='myfunction($id,1)'>&#8679;</button><button onclick='myfunction($id,-1)'>&#8681;</button><br>
  87. <br>$tagdisp $tagdisp2 $tagdisp3<br>
  88. <p style='color: grey'>$timestamp</p><hr>
  89. </div>
  90. ";
  91. }
  92.  
  93. elseif(in_array($info['extension'], $vid)) {
  94. echo " <div class='card'>
  95. <h3>Handle: $handle</h3><br />
  96. <p>$comment</p><br /><br />
  97. <video controls='controls' width='70%' src='$file' style='border-style: solid'></video><br>
  98. <p>Post #$id</p>
  99. <p id='scorecount-$id'>Score: $score</p><br>
  100. <button onclick='myfunction($id,1)'>&#8679;</button><button onclick='myfunction($id,-1)'>&#8681;</button><br>
  101. <br>$tagdisp $tagdisp2 $tagdisp3<br>
  102. <p style='color: grey'>$timestamp</p><hr>
  103. </div>
  104. ";
  105. }
  106.  
  107. else {
  108.  
  109. echo " <div class='card'>
  110. <h3>Handle: $handle</h3><br />
  111. <p>$comment</p><br /><br />
  112. <a href='$file'><h3>Click Here To View Attached File</h3></a><br>
  113. <p>Post #$id</p>
  114. <p id='scorecount-$id'>Score: $score</p><br>
  115. <button onclick='myfunction($id,1)'>&#8679;</button><button onclick='myfunction($id,-1)'>&#8681;</button><br>
  116. <br>$tagdisp $tagdisp2 $tagdisp3<br>
  117. <p style='color: grey'>$timestamp</p><hr>
  118. </div>
  119. ";
  120.  
  121. }
  122. }
  123.  
  124. elseif($ytlink != NULL) {
  125.  
  126. echo " <div class='card'>
  127. <h3>Handle: $handle</h3><br />
  128. <p>$comment</p><br /><br />
  129. <iframe width="420" height="315" src="http://www.youtube.com/embed/$ytcode" frameborder="0" allowfullscreen></iframe><br />
  130. <p>Post #$id</p>
  131. <p id='scorecount-$id'>Score: $score</p><br>
  132. <button onclick='myfunction($id,1)'>&#8679;</button><button onclick='myfunction($id,-1)'>&#8681;</button><br>
  133. <br>$tagdisp $tagdisp2 $tagdisp3<br>
  134. <p style='color: grey'>$timestamp</p><hr>
  135. </div>
  136. ";
  137.  
  138. }
  139.  
  140. else {
  141.  
  142. echo " <div class='card'>
  143. <h3>Handle: $handle</h3><br />
  144. <p>$comment</p><br />
  145. <p>Post #$id</p>
  146. <p id='scorecount-$id'>Score: $score</p><br>
  147. <button onclick='myfunction($id,1)'>&#8679;</button><button onclick='myfunction($id,-1)'>&#8681;</button><br>
  148. <br>$tagdisp $tagdisp2 $tagdisp3<br>
  149. <p style='color: grey'>$timestamp</p><hr>
  150. </div>
  151. ";
  152.  
  153. }
  154.  
  155. }
  156.  
  157. if($tag == 'explicit' OR $tag2 == 'explicit' OR $tag3 == 'explicit'){
  158.  
  159. if ($file != NULL) {
  160.  
  161. if (in_array($info['extension'], $display)){
  162.  
  163. echo " <div class='cardexp'>
  164. <h3>Handle: $handle</h3><br />
  165. <p>$comment</p><br /><br />
  166. <img src='$file' style='width:70%; margin-left:15%; margin-right:15%; margin-top:5px; border-style:solid;'><br>
  167. <p>Post #$id</p>
  168. <p id='scorecount-$id'>Score: $score</p><br>
  169. <button onclick='myfunction($id,1)'>&#8679;</button><button onclick='myfunction($id,-1)'>&#8681;</button><br>
  170. <br>$tagdisp $tagdisp2 $tagdisp3<br>
  171. <p style='color: grey'>$timestamp</p><hr>
  172. </div>
  173. ";
  174. }
  175.  
  176. elseif(in_array($info['extension'], $vid)) {
  177. echo " <div class='cardexp'>
  178. <h3>Handle: $handle</h3><br />
  179. <p>$comment</p><br /><br />
  180. <video controls='controls' width='70%' src='$file' style='border-style: solid'></video><br>
  181. <p>Post #$id</p>
  182. <p id='scorecount-$id'>Score: $score</p><br>
  183. <button onclick='myfunction($id,1)'>&#8679;</button><button onclick='myfunction($id,-1)'>&#8681;</button><br>
  184. <br>$tagdisp $tagdisp2 $tagdisp3<br>
  185. <p style='color: grey'>$timestamp</p><hr>
  186. </div>
  187. ";
  188. }
  189.  
  190. else {
  191.  
  192. echo " <div class='cardexp'>
  193. <h3>Handle: $handle</h3><br />
  194. <p>$comment</p><br /><br />
  195. <a href='$file'><h3>Click Here To View Attached File</h3></a><br>
  196. <p>Post #$id</p>
  197. <p id='scorecount-$id'>Score: $score</p><br>
  198. <button onclick='myfunction($id,1)'>&#8679;</button><button onclick='myfunction($id,-1)'>&#8681;</button><br>
  199. <br>$tagdisp $tagdisp2 $tagdisp3<br>
  200. <p style='color: grey'>$timestamp</p><hr>
  201. </div>
  202. ";
  203.  
  204. }
  205. }
  206.  
  207. elseif($ytlink != NULL) {
  208.  
  209. echo " <div class='cardexp'>
  210. <h3>Handle: $handle</h3><br />
  211. <p>$comment</p><br /><br />
  212. <iframe width="420" height="315" src="http://www.youtube.com/embed/$ytcode" frameborder="0" allowfullscreen></iframe><br />
  213. <p>Post #$id</p>
  214. <p id='scorecount-$id'>Score: $score</p><br>
  215. <button onclick='myfunction($id,1)'>&#8679;</button><button onclick='myfunction($id,-1)'>&#8681;</button><br>
  216. <br>$tagdisp $tagdisp2 $tagdisp3<br>
  217. <p style='color: grey'>$timestamp</p><hr>
  218. </div>
  219. ";
  220.  
  221. }
  222.  
  223.  
  224. else {
  225.  
  226. echo " <div class='cardexp'>
  227. <h3>Handle: $handle</h3><br />
  228. <p>$comment</p><br />
  229. <p>Post #$id</p>
  230. <p id='scorecount-$id'>Score: $score</p><br>
  231. <button onclick='myfunction($id,1)'>&#8679;</button><button onclick='myfunction($id,-1)'>&#8681;</button><br>
  232. <br>$tagdisp $tagdisp2 $tagdisp3<br>
  233. <p style='color: grey'>$timestamp</p><hr>
  234. </div>
  235. ";
  236.  
  237. }
  238.  
  239. }
  240.  
  241. }
  242.  
  243. mysqli_close($con);
  244.  
  245. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement