PageRenderTime 26ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/modules/Forum/main.php

https://code.google.com/p/nuked-klan/
PHP | 225 lines | 178 code | 39 blank | 8 comment | 40 complexity | 6e7f3c1d6c03e92bb357fd5619925d46 MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause, GPL-2.0, LGPL-3.0, LGPL-2.1
  1. <?php
  2. // -------------------------------------------------------------------------//
  3. // Nuked-KlaN - PHP Portal //
  4. // http://www.nuked-klan.org //
  5. // -------------------------------------------------------------------------//
  6. // This program is free software. you can redistribute it and/or modify //
  7. // it under the terms of the GNU General Public License as published by //
  8. // the Free Software Foundation; either version 2 of the License. //
  9. // -------------------------------------------------------------------------//
  10. defined('INDEX_CHECK') or die ('You can\'t run this file alone.');
  11. global $user, $nuked, $language, $cookie_forum;
  12. include('modules/Forum/template.php');
  13. $visiteur = $user ? $user[1] : 0;
  14. $user_last_visit = (empty($user[4])) ? time() : $user[4];
  15. $date_jour = nkDate(time());
  16. $your_last_visite = nkDate($user_last_visit);
  17. if ($nuked['forum_title'] != "")
  18. {
  19. $title = "<big><b>" . $nuked['forum_title'] . "</b></big><br />" . $nuked['forum_desc'];
  20. }
  21. else
  22. {
  23. $title = "<big><b>Forums " . $nuked['name'] . "</b></big><br />" . $nuked['slogan'];
  24. }
  25. if ($_REQUEST['cat'] != "")
  26. {
  27. $sql_cat = mysql_query("SELECT nom FROM " . FORUM_CAT_TABLE . " WHERE id = '" . $_REQUEST['cat'] . "'");
  28. list($cat_name) = mysql_fetch_row($sql_cat);
  29. $cat_name = printSecuTags($cat_name);
  30. $nav = "&nbsp;-&gt; <b>" . $cat_name . "</b>";
  31. }
  32. echo "<br /><form method=\"get\" action=\"index.php\">\n"
  33. . "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\">\n"
  34. . "<tr><td style=\"width: 50%;\" align=\"center\">" . $title . "</td>\n"
  35. . "<td style=\"width: 50%;\" align=\"right\"><br /><b>" . _SEARCH . " :</b> <input type=\"text\" name=\"query\" size=\"25\" /><br />\n"
  36. . "[ <a href=\"index.php?file=Forum&amp;page=search\">" . _ADVANCEDSEARCH . "</a> ]&nbsp;"
  37. . "<input type=\"hidden\" name=\"file\" value=\"Forum\" />\n"
  38. . "<input type=\"hidden\" name=\"page\" value=\"search\" />\n"
  39. . "<input type=\"hidden\" name=\"do\" value=\"search\" />\n"
  40. . "<input type=\"hidden\" name=\"into\" value=\"all\" /></td></tr></table></form>\n"
  41. . "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"4\" border=\"0\">\n"
  42. . "<tr><td valign=\"bottom\"><a href=\"index.php?file=Forum\"><b>" . _INDEXFORUM . "</b></a>" . $nav . "</td><td align=\"right\" valign=\"bottom\"><small>" . _DAYIS . " : " . $date_jour;
  43. if ($user && $user[4] != "")
  44. {
  45. echo "<br />" . _LASTVISIT . " : " . $your_last_visite;
  46. }
  47. echo "</small></td></tr></table>\n"
  48. . "<table style=\"background: " . $color3 . ";\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"4\">\n"
  49. . "<tr " . $background . ">\n"
  50. . "<td style=\"width: 5%;\">&nbsp;</td>\n"
  51. . "<td style=\"width: 40%;\" align=\"center\"><b>" . _FORUMS . "</b></td>\n"
  52. . "<td style=\"width: 15%;\" align=\"center\"><b>" . _SUBJECTS . "</b></td>\n"
  53. . "<td style=\"width: 15%;\" align=\"center\"><b>" . _MESSAGES . "</b></td>\n"
  54. . "<td style=\"width: 25%;\" align=\"center\"><b>" . _LASTPOST . "</b></td></tr>\n";
  55. if ($_REQUEST['cat'] != "")
  56. {
  57. $main = mysql_query("SELECT nom, id FROM " . FORUM_CAT_TABLE . " WHERE '" . $visiteur . "' >= niveau AND id = '" . $_REQUEST['cat'] . "'");
  58. }
  59. else
  60. {
  61. $main = mysql_query("SELECT nom, id FROM " . FORUM_CAT_TABLE . " WHERE " . $visiteur . " >= niveau ORDER BY ordre, nom");
  62. }
  63. while (list($nom_cat, $cid) = mysql_fetch_row($main))
  64. {
  65. $nom_cat = printSecuTags($nom_cat);
  66. echo "<tr " . $background_cat . "><td colspan=\"5\">&nbsp;&nbsp;<a href=\"index.php?file=Forum&amp;cat=" . $cid . "\"><big><b>" . $nom_cat . "</b></big></a></td></tr>\n";
  67. $sql = mysql_query("SELECT nom, comment, id from " . FORUM_TABLE . " WHERE cat = '" . $cid . "' AND '" . $visiteur . "' >= niveau ORDER BY ordre, nom");
  68. while (list($nom, $comment, $forum_id) = mysql_fetch_row($sql))
  69. {
  70. $nom = printSecuTags($nom);
  71. $req2 = mysql_query("SELECT forum_id from " . FORUM_THREADS_TABLE . " WHERE forum_id = '" . $forum_id . "'");
  72. $num_post = mysql_num_rows($req2);
  73. $req3 = mysql_query("SELECT forum_id from " . FORUM_MESSAGES_TABLE . " WHERE forum_id = '" . $forum_id . "'");
  74. $num_mess = mysql_num_rows($req3);
  75. $req4 = mysql_query("SELECT MAX(id) from " . FORUM_MESSAGES_TABLE . " WHERE forum_id = '" . $forum_id . "'");
  76. $idmax = mysql_result($req4, 0, "MAX(id)");
  77. $req5 = mysql_query("SELECT id, thread_id, date, auteur, auteur_id FROM " . FORUM_MESSAGES_TABLE . " WHERE id = '" . $idmax . "'");
  78. list($mess_id, $thid, $date, $auteur, $auteur_id) = mysql_fetch_array($req5);
  79. $auteur = nk_CSS($auteur);
  80. if ($user) {
  81. $visits = mysql_query("SELECT user_id, forum_id FROM " . FORUM_READ_TABLE . " WHERE user_id = '" . $user[0] . "' AND forum_id LIKE '%" . ',' . $forum_id . ',' . "%' ");
  82. $results = mysql_fetch_assoc($visits);
  83. if ($num_post > 0 && strrpos($results['forum_id'], ',' . $forum_id . ',') === false) {
  84. $img = "<img src=\"modules/Forum/images/forum_new.gif\" alt=\"\" />";
  85. }
  86. else
  87. {
  88. $img = "<img src=\"modules/Forum/images/forum.gif\" alt=\"\" />";
  89. }
  90. }
  91. else
  92. {
  93. $img = "<img src=\"modules/Forum/images/forum.gif\" alt=\"\" />";
  94. }
  95. echo "<tr style=\"background: " . $color2 . ";\">\n"
  96. . "<td style=\"width: 5%;\" align=\"center\">" . $img . "</td>\n"
  97. . "<td style=\"width: 40%;\" onmouseover=\"this.style.backgroundColor='" . $color1 . "'; this.style.cursor='hand';\" onmouseout=\"this.style.backgroundColor='" . $color2 . "'\" onclick=\"document.location='index.php?file=Forum&amp;page=viewforum&amp;forum_id=" . $forum_id . "'\"><a href=\"index.php?file=Forum&amp;page=viewforum&amp;forum_id=" . $forum_id . "\"><big><b>" . $nom ." </b></big></a><br />" . $comment . "</td>\n";
  98. $sql_page = mysql_query("SELECT thread_id FROM " . FORUM_MESSAGES_TABLE . " WHERE thread_id = '" . $thid . "'");
  99. $nb_rep = mysql_num_rows($sql_page);
  100. if ($nb_rep > $nuked['mess_forum_page'])
  101. {
  102. $topicpages = $nb_rep / $nuked['mess_forum_page'];
  103. $topicpages = ceil($topicpages);
  104. $link_post = "index.php?file=Forum&amp;page=viewtopic&amp;forum_id=" . $forum_id . "&amp;thread_id=" . $thid . "&amp;p=" . $topicpages . "#" . $mess_id;
  105. }
  106. else
  107. {
  108. $link_post = "index.php?file=Forum&amp;page=viewtopic&amp;forum_id=" . $forum_id . "&amp;thread_id=" . $thid . "#" . $mess_id;
  109. }
  110. echo "<td style=\"width: 15%;\" align=\"center\">" . $num_post . "</td>\n"
  111. . "<td style=\"width: 15%;\" align=\"center\">" . $num_mess . "</td>\n"
  112. . "<td style=\"width: 25%;\" align=\"center\"> ";
  113. if ($num_mess > 0)
  114. {
  115. if ($auteur_id != "")
  116. {
  117. $sq_user = mysql_query("SELECT pseudo, country FROM " . USER_TABLE . " WHERE id = '" . $auteur_id . "'");
  118. $test = mysql_num_rows($sq_user);
  119. list($author, $country) = mysql_fetch_array($sq_user);
  120. if ($test > 0 && $author != "")
  121. {
  122. $autor = $author;
  123. }
  124. else
  125. {
  126. $autor = $auteur;
  127. }
  128. }
  129. else
  130. {
  131. $autor = $auteur;
  132. }
  133. if (strftime("%d %m %Y", time()) == strftime("%d %m %Y", $date)) $date = _FTODAY . "&nbsp;" . strftime("%H:%M", $date);
  134. else if (strftime("%d", $date) == (strftime("%d", time()) - 1) && strftime("%m %Y", time()) == strftime("%m %Y", $date)) $date = _FYESTERDAY . "&nbsp;" . strftime("%H:%M", $date);
  135. else $date = nkDate($date);
  136. echo $date . "<br />";
  137. if ($auteur_id != "")
  138. {
  139. echo "<a href=\"index.php?file=Members&amp;op=detail&amp;autor=" . urlencode($autor) . "\"><b>" . $autor . "</b></a>";
  140. }
  141. else
  142. {
  143. echo "<b>" . $autor . "</b>";
  144. }
  145. echo "&nbsp;<a href=\"" . $link_post . "\"><img style=\"border: 0;\" src=\"modules/Forum/images/icon_latest_reply.gif\" alt=\"\" title=\"" . _SEELASTPOST . "\" /></a>";
  146. }
  147. else
  148. {
  149. echo _NOPOST;
  150. }
  151. echo "</td></tr>\n";
  152. }
  153. }
  154. $nb = nbvisiteur();
  155. echo "<tr " . $background . "><td colspan=\"5\"><b>" . _FWHOISONLINE . "</b></td></tr>\n"
  156. . "<tr style=\"background: " . $color2 . ";\"><td><img src=\"modules/Forum/images/whosonline.gif\" alt=\"\" /></td>\n"
  157. . "<td colspan=\"4\">" . _THEREARE . "&nbsp;" . $nb[0] . "&nbsp;" . _FVISITORS . ", " . $nb[1] . "&nbsp;" . _FMEMBERS . "&nbsp;" . _AND . "&nbsp;" . $nb[2] . "&nbsp;" . _FADMINISTRATORS . "&nbsp;" . _ONLINE . "<br />" . _MEMBERSONLINE . " : ";
  158. $i = 0;
  159. $online = mysql_query("SELECT username FROM " . NBCONNECTE_TABLE . " WHERE type > 0 ORDER BY date");
  160. while (list($name) = mysql_fetch_row($online))
  161. {
  162. $i++;
  163. if ($i == $nb[3])
  164. {
  165. $sep = "";
  166. }
  167. else
  168. {
  169. $sep = ", ";
  170. }
  171. echo "<a href=\"index.php?file=Members&amp;op=detail&amp;autor=" . urlencode($name) . "\">" . $name . "</a>" . $sep;
  172. }
  173. if (mysql_num_rows($online) == NULL) echo '<em>' . _NONE . '</em>';
  174. echo "</td></tr></table><div style=\"text-align: right;\">";
  175. if ($user)
  176. {
  177. echo "<a href=\"index.php?file=Forum&amp;op=mark\">" . _MARKREAD . "</a>";
  178. }
  179. if ($user && $user[4] != "")
  180. {
  181. echo "<br /><a href=\"index.php?file=Forum&amp;page=search&amp;do=search&amp;date_max=" . $user[4] . "\">" . _VIEWLASTVISITMESS . "</a>";
  182. }
  183. echo "</div><table cellspacing=\"0\" cellpadding=\"2\" border=\"0\">\n"
  184. . "<tr><td><img src=\"modules/Forum/images/forum_new.gif\" alt=\"\" /></td><td valign=\"middle\">&nbsp;" . _NEWSPOSTLASTVISIT . "</td></tr>\n"
  185. . "<tr><td><img src=\"modules/Forum/images/forum.gif\" alt=\"\" /></td><td valign=\"middle\">&nbsp;" . _NOPOSTLASTVISIT . "</td></tr></table><br />\n";
  186. ?>