read.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <style>
  2. .center {
  3. margin-left: auto;
  4. margin-right: auto;
  5. font-size: 32px;
  6. }
  7. p {text-align: center;}
  8. </style>
  9. <?php
  10. include 'functions.php';
  11. $ID=$_GET["ID"];
  12. $ShowUser=$_GET["User"];
  13. if($ID!="")
  14. {
  15. $sql = "SELECT Name, Text, Options, Image FROM stor WHERE RefID=?";
  16. $stmt = $conn->prepare($sql);
  17. $stmt->bind_param("i", $ID);
  18. $stmt->execute();
  19. $result = $stmt->get_result();
  20. if ($result->num_rows > 0)
  21. {
  22. // output data of each row
  23. while($row = $result->fetch_assoc())
  24. {
  25. echo '<table class="center">
  26. <tr>
  27. <th>' . applyBB($row["Name"]) . ' </th>
  28. </tr>';
  29. if($row["Image"]!="0")
  30. {
  31. $imLink="images/0.jpg";
  32. $sql3 = "SELECT Link, Unlocked, Alt FROM Images WHERE ID=?";
  33. $stmt = $conn->prepare($sql3);
  34. $into=$row["Image"];
  35. $stmt->bind_param("i", $into);
  36. $stmt->execute();
  37. $result3 = $stmt->get_result();
  38. $imDes="";
  39. while($row2 = $result3->fetch_assoc())
  40. {
  41. if($row2["Unlocked"]=='1')
  42. {
  43. $imLink=$row2["Link"];
  44. $imDes=$row2["Alt"];
  45. }
  46. }
  47. echo '<tr>
  48. <td><p></align><img src="' . $imLink . '" alt="'. htmlentities($imDes) .'" style="width:400px;"></p></td>
  49. </tr>';
  50. }
  51. echo '<tr>
  52. <td>' . nl2br(applyBB($row["Text"])) . '</td>
  53. </tr>
  54. <tr>
  55. <td></td>
  56. </tr>';
  57. $Options=$row["Options"];
  58. if($Options!="")
  59. {
  60. $choices= explode(" ", $Options);
  61. $arrLength = count($choices);
  62. $l=1;
  63. for($i = 0; $i < $arrLength; $i++)
  64. {
  65. $sql2 = "SELECT Description FROM stor WHERE RefID=?";
  66. $stmt = $conn->prepare($sql2);
  67. $stmt->bind_param("i", $choices[$i]);
  68. $stmt->execute();
  69. $result2 = $stmt->get_result();
  70. while($row2 = $result2->fetch_assoc())
  71. {
  72. if($row2["Description"]!="")
  73. {
  74. echo "<tr><td><a href=index.php?ID=".$choices[$i]."> " . $l . ": " ;
  75. echo htmlentities($row2["Description"]);
  76. echo "</a></td></tr> ";
  77. $l=$l+1;
  78. }
  79. }
  80. }
  81. }
  82. echo "</table>";
  83. }
  84. }
  85. else
  86. {
  87. echo "Invalid ID";
  88. }
  89. }
  90. else
  91. {
  92. if($ShowUser=='')
  93. {
  94. echo '<p style="font-size:32px; ">Available Stories: </p>';
  95. $sql = "SELECT ID, Title, Opener, Description, Owner FROM Stories ORDER BY rand()";
  96. $stmt = $conn->prepare($sql);
  97. $stmt->execute();
  98. $result = $stmt->get_result();
  99. echo "<br>";
  100. if ($result->num_rows > 0)
  101. {
  102. while($row = $result->fetch_assoc())
  103. {
  104. echo "<br><a href=index.php?ID=".$row["Opener"].">".htmlentities($row["Title"])."</a> <br> <i>".htmlentities($row["Description"])."</i>" ;
  105. if($_SESSION['Level']>=$ModPermissionLevel)
  106. echo " <a href=index.php?Mod=6&ID=".$row["ID"].">Edit</a>";
  107. echo "<br>";
  108. }
  109. }
  110. }
  111. else
  112. {
  113. if(is_numeric($ShowUser) && ($ShowUser==$_SESSION['ID'] || $_SESSION['Level']>=$ModPermissionLevel))
  114. {
  115. echo "User ID " . $ShowUser . "<br><br> <b>Stories:</b> ";
  116. $sql = "SELECT ID, Title, Opener, Description, Owner FROM Stories";
  117. $stmt = $conn->prepare($sql);
  118. $stmt->execute();
  119. $result = $stmt->get_result();
  120. echo "<br>";
  121. if ($result->num_rows > 0)
  122. {
  123. while($row = $result->fetch_assoc())
  124. {
  125. if($row["Owner"]==$ShowUser)
  126. echo "<br><a href=index.php?ID=".$row["Opener"].">".htmlentities($row["Title"])."</a> <br> <i>".htmlentities($row["Description"])."</i> - <a href=index.php?Mod=6&ID=".$row["ID"].">Edit</a><br>" ;
  127. }
  128. }
  129. echo "<br> <b>Pages:</b> ";
  130. $sql = "SELECT Name, Text, Owner, RefID FROM stor";
  131. $stmt = $conn->prepare($sql);
  132. $stmt->execute();
  133. $result = $stmt->get_result();
  134. echo "<br>";
  135. if ($result->num_rows > 0)
  136. {
  137. while($row = $result->fetch_assoc())
  138. {
  139. if($row["Owner"]==$ShowUser)
  140. echo "<br><a href=index.php?ID=".$row["RefID"].">".htmlentities($row["Name"])."</a> - <i>".htmlentities(substr($row["Text"], 0, 50))."...</i> - <a href=index.php?ID=".$row["RefID"]."&Mod=1>Edit</a>" ;
  141. }
  142. }
  143. echo "<br><br> <b>Images:</b> ";
  144. $sql = "SELECT Link, Unlocked, Uploader, License, Alt, ID FROM Images";
  145. $stmt = $conn->prepare($sql);
  146. $stmt->execute();
  147. $result = $stmt->get_result();
  148. echo "<br>";
  149. if ($result->num_rows > 0)
  150. {
  151. while($row = $result->fetch_assoc())
  152. {
  153. if($row["Uploader"]==$ShowUser && $row["Unlocked"]=='1')
  154. echo '<br><img src="' . $row["Link"] .'" alt="'. htmlentities($row["Alt"]) .'" style="width:125;height:100px;"><br>ID:'.$row["ID"].' License: '.htmlentities($row["License"]).' Alt Text: '.$row["Alt"].'<br>';
  155. }
  156. }
  157. }
  158. }
  159. }
  160. ?>