phpDocumentor koliportal
[ class tree: koliportal ] [ index: koliportal ] [ all elements ]

Source for file forum_topic.php

Documentation is available at forum_topic.php

  1. <?php
  2. /** Fórum hozzászólásokat megjelenítő szkript
  3. * @package koliportal
  4. * @author Karakó Miklós <palacsint_X_freemail.hu>
  5. * @copyright Copyright &copy; 2005, Karakó Miklós
  6. */
  7. $post = 'béta';
  8. $posts_errc = 1;
  9. // FIXME: lapozgatást meg kellene oldani
  10. /*
  11. function showhex($t)
  12. {
  13. $len = strlen($t);
  14. for ($i = 0; $i < $len; $i++)
  15. {
  16. printf("%d - ", ord($t[$i]));
  17. }
  18. }
  19. */
  20.  
  21. $show_header = $show_posts = false;
  22. if (0 === $errc)
  23. {
  24. $tid = $_GET["tid"];
  25. $topic_q = "SELECT * FROM topics WHERE tid = '$tid'";
  26. $topic_res = mysql_query($topic_q, $database);
  27. if ((false === $topic_res))
  28. {
  29. forum_msg("A hozzászólások lékérdezése nem sikerült!", FORUM_ERR);
  30. mylog(sprintf("forum - getposts: %s", mysql_error()));
  31. $errc++;
  32. }
  33. }
  34.  
  35. if (0 === $errc)
  36. {
  37. $tarr = mysql_fetch_assoc($topic_res);
  38. if (false === $tarr)
  39. {
  40. forum_msg("A hozzászólások lékérdezése nem sikerült!", FORUM_ERR);
  41. mylog(sprintf("forum - getposts2: %s", mysql_error()));
  42. $errc++;
  43. } else {
  44. $topic_header = true;
  45. }
  46. }
  47.  
  48.  
  49.  
  50.  
  51. if ((0 === $errc) && (isset($_POST["newpost"])) && (isset($_POST["post"])))
  52. {
  53. $post = trim($_POST["post"]);
  54.  
  55. // FIXME: általános ellenőrzést belőle!
  56. $uid = $_SESSION["sid"];
  57. if (!is_numeric($uid))
  58. {
  59. forum_msg("Belső hiba!", FORUM_ERR);
  60. }
  61. if (false === $_SESSION["login"])
  62. {
  63. forum_msg("Csak bejelentkezett felhasználó írhat új hozzászólást!", FORUM_ERR);
  64. $errc++;
  65. }
  66.  
  67.  
  68. if ((0 === $errc) && (strlen($post) < 5))
  69. {
  70. forum_msg("A hozzászólás túl rövid!", FORUM_MSG);
  71. $errc++;
  72. }
  73. if (0 === $errc)
  74. {
  75. t_start();
  76. $t = addslashes($post);
  77. $t = $post;
  78. $sql_i = "INSERT INTO posts (uid, tid, dt, t)
  79. VALUES ('$uid', '$tid', CURRENT_TIMESTAMP, '$t')";
  80. $i_res = mysql_query($sql_i, $database);
  81. if (false === $i_res)
  82. {
  83. forum_msg("A hozzászólás elküldése nem sikerült!", FORUM_ERR);
  84. mylog(sprintf("forum - sendposts: %s", mysql_error()));
  85. t_rollback();
  86. $errc++;
  87. } else {
  88. t_commit();
  89. }
  90. }
  91. }
  92.  
  93.  
  94.  
  95. $posts_q = "SELECT * FROM posts WHERE tid = '$tid'";
  96. $posts_res = mysql_query($posts_q, $database);
  97. if ((false === $posts_res))
  98. {
  99. forum_msg("A hozzászólások lékérdezése nem sikerült!", FORUM_ERR);
  100. mylog(sprintf("forum - getposts: %s", mysql_error()));
  101. $errc++;
  102. } else {
  103. $show_posts = true;
  104. }
  105.  
  106. ?>
  107.  
  108. <form action="<?= $_SERVER["PHP_SELF"] ?>?page=<?= $page ?>&amp;tid=<?= $tid ?>" id="np_form" method="post">
  109.  
  110. <table id="topics" border="1">
  111.  
  112. <?php
  113. if ($show_header)
  114. {
  115. ?>
  116.  
  117. <tr>
  118. <th colspan="2"><?= $tarr["title"] ?></th>
  119. </tr>
  120.  
  121. <?php
  122. }
  123. ?>
  124.  
  125.  
  126. <?php
  127. if ($show_posts)
  128. {
  129. while ($arr = mysql_fetch_assoc($posts_res))
  130. {
  131. ?>
  132. <tr>
  133. <th><?= get_student_name($arr["uid"]) ?></th>
  134. <th><?= $arr["dt"] ?></th>
  135. </tr>
  136. <tr>
  137. <td colspan="2"><?= $arr["t"] ?></td>
  138. </tr>
  139.  
  140. <?php
  141. }
  142. }
  143. ?>
  144.  
  145.  
  146.  
  147.  
  148.  
  149. <tr>
  150. <th colspan="2">Új hozzászólás: </th>
  151. </tr>
  152. <tr>
  153. <td colspan="2">
  154. <textarea name="post" cols="80" rows="6"><?= $post ?>x</textarea>
  155. </td>
  156. </tr>
  157.  
  158. <tr>
  159. <th><input type="submit" value="Elküld" /></th>
  160. <th>
  161. <input type="hidden" name="newpost" value="newpost" />
  162. </th>
  163. </tr>
  164.  
  165. </table>
  166.  
  167. </form>
  168. <?php
  169.  
  170. ?>

Documentation generated on Wed, 18 May 2005 19:24:20 +0200 by phpDocumentor 1.3.0RC3