reader.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <html>
  2. <style>
  3. .center {
  4. margin-left: auto;
  5. margin-right: auto;
  6. font-size: 32px;
  7. }
  8. p {text-align: center;}
  9. </style>
  10. <?php
  11. include 'functions.php';
  12. include 'config.php';
  13. $ID=$_GET["ID"];
  14. $ShowUser=$_GET["User"];
  15. if($ID!="")
  16. {
  17. $sql = "SELECT Name, Text, Options, Image FROM stor WHERE RefID=?";
  18. $stmt = $conn->prepare($sql);
  19. $stmt->bind_param("i", $ID);
  20. $stmt->execute();
  21. $result = $stmt->get_result();
  22. if ($result->num_rows > 0)
  23. {
  24. // output data of each row
  25. while($row = $result->fetch_assoc())
  26. {
  27. echo '<table class="center">
  28. <tr>
  29. <th>' . applyBB($row["Name"]) . ' </th>
  30. </tr>';
  31. if($row["Image"]!="0")
  32. {
  33. $imLink="images/0.jpg";
  34. $sql3 = "SELECT Link, Unlocked, Alt FROM Images WHERE ID=?";
  35. $stmt = $conn->prepare($sql3);
  36. $into=$row["Image"];
  37. $stmt->bind_param("i", $into);
  38. $stmt->execute();
  39. $result3 = $stmt->get_result();
  40. $imDes="";
  41. while($row2 = $result3->fetch_assoc())
  42. {
  43. if($row2["Unlocked"]=='1')
  44. {
  45. $imLink=$row2["Link"];
  46. $imDes=$row2["Alt"];
  47. }
  48. }
  49. echo '<tr>
  50. <td><p></align><img src="' . $imLink . '" alt="'. htmlentities($imDes) .'" style="width:400px;"></p></td>
  51. </tr>';
  52. }
  53. echo '<tr>
  54. <td>' . nl2br(applyBB($row["Text"])) . '</td>
  55. </tr>
  56. <tr>
  57. <td></td>
  58. </tr>';
  59. $Options=$row["Options"];
  60. if($Options!="")
  61. {
  62. $choices= explode(" ", $Options);
  63. $arrLength = count($choices);
  64. $l=1;
  65. for($i = 0; $i < $arrLength; $i++)
  66. {
  67. $sql2 = "SELECT Description FROM stor WHERE RefID=?";
  68. $stmt = $conn->prepare($sql2);
  69. $stmt->bind_param("i", $choices[$i]);
  70. $stmt->execute();
  71. $result2 = $stmt->get_result();
  72. while($row2 = $result2->fetch_assoc())
  73. {
  74. if($row2["Description"]!="")
  75. {
  76. echo "<tr><td><a href=reader.php?ID=".$choices[$i]."> " . $l . ": " ;
  77. echo htmlentities($row2["Description"]);
  78. echo "</a></td></tr> ";
  79. $l=l+1;
  80. }
  81. }
  82. }
  83. }
  84. echo "</table>";
  85. }
  86. }
  87. else
  88. {
  89. echo "Invalid ID";
  90. }
  91. }
  92. else
  93. {
  94. if($ShowUser=='')
  95. {
  96. echo '<p style="font-size:32px; ">Available Stories: </p>';
  97. $sql = "SELECT ID, Title, Opener, Description, Owner FROM Stories ORDER BY rand()";
  98. $stmt = $conn->prepare($sql);
  99. $stmt->execute();
  100. $result = $stmt->get_result();
  101. echo "<br>";
  102. if ($result->num_rows > 0)
  103. {
  104. while($row = $result->fetch_assoc())
  105. {
  106. echo "<br><a href=reader.php?ID=".$row["Opener"].">".htmlentities($row["Title"])."</a> <br> <i>".htmlentities($row["Description"])."</i>" ;
  107. echo "<br>";
  108. }
  109. }
  110. }
  111. else
  112. {
  113. }
  114. }
  115. ?>
  116. </html>