Codechange: Gruppierung der Ausgabe der Benutzerliste, Tabellen mit <thead> und ...
[wmmkf.git] / board.php
blobc5ebd471ccf617a61d1d7ab0edc2b7b3e79b16ac
1 <?php
2 ###############################################################################
3 # my little forum #
4 # Copyright (C) 2004 Alex #
5 # http://www.mylittlehomepage.net/ #
6 # #
7 # This program is free software; you can redistribute it and/or #
8 # modify it under the terms of the GNU General Public License #
9 # as published by the Free Software Foundation; either version 2 #
10 # of the License, or (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program; if not, write to the Free Software #
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
20 ###############################################################################
22 include("inc.php");
23 include_once("functions/include.prepare.php");
26 if (!isset($_SESSION[$settings['session_prefix'].'user_id'])
27 && isset($_COOKIE['auto_login'])
28 && isset($settings['autologin'])
29 && $settings['autologin'] == 1)
31 header("location: ".$settings['forum_address']."login.php?referer=board.php");
32 die("<a href=\"login.php?referer=board.php\">further...</a>");
35 if($settings['access_for_users_only'] == 1
36 && isset($_SESSION[$settings['session_prefix'].'user_name'])
37 || $settings['access_for_users_only'] != 1)
39 if ($settings['remember_userstandard'] == 1
40 && !isset($_SESSION[$settings['session_prefix'].'newtime']))
42 setcookie("user_view","board",time()+(3600*24*30));
45 unset($zeile);
46 $ul = $_SESSION[$settings['session_prefix'].'page'] * $settings['topics_per_page'];
48 # database request
49 # no categories defined
50 if ($categories === false)
52 $threadsQueryWhere = '';
54 # there are categories and all categories should be shown
55 else if (is_array($categories)
56 && $_SESSION[$settings['session_prefix'].'category'] == 0)
58 $threadsQueryWhere = " AND category IN (".$category_ids_query.")";
60 # there are categories and only one category should be shown
61 else if (is_array($categories)
62 && $_SESSION[$settings['session_prefix'].'category'] != 0
63 && in_array($_SESSION[$settings['session_prefix'].'category'], $category_ids))
65 $threadsQueryWhere = " AND category = '". mysql_real_escape_string($_SESSION[$settings['session_prefix'].'category']) ."'";
66 // how many entries?
67 $pid_result = mysql_query("SELECT COUNT(*) FROM ".$db_settings['forum_table']." WHERE pid = 0 AND category = '". mysql_real_escape_string($_SESSION[$settings['session_prefix'].'category']) ."'", $connid);
68 list($thread_count) = mysql_fetch_row($pid_result);
69 mysql_free_result($pid_result);
71 # list all threads
72 $threadsQuery = "SELECT
73 tid,
74 t1.user_id AS posters_id,
75 DATE_FORMAT(time + INTERVAL ".$time_difference." HOUR, '".$lang['time_format_sql']."') AS Uhrzeit,
76 DATE_FORMAT(last_answer + INTERVAL ".$time_difference." HOUR, '".$lang['time_format_sql']."') AS la_Uhrzeit,
77 UNIX_TIMESTAMP(last_answer) AS last_answer,
78 name,
79 subject,
80 category,
81 views,
82 fixed,
83 (SELECT
84 user_type
85 FROM ".$db_settings['userdata_table']."
86 WHERE ".$db_settings['userdata_table'].".user_id = posters_id) AS user_type
87 FROM ".$db_settings['forum_table']." AS t1
88 WHERE pid = 0".$threadsQueryWhere."
89 ORDER BY fixed DESC, ".$_SESSION[$settings['session_prefix'].'order']." ".$_SESSION[$settings['session_prefix'].'descasc']."
90 LIMIT ".$ul.", ".$settings['topics_per_page'];
91 $threadsResult = mysql_query($threadsQuery, $connid);
92 if (!$threadsResult) die($lang['db_error']);
94 $subnav_1 = outputPostingLink($_SESSION[$settings['session_prefix'].'category'], "board");
95 $pagination = ($_SESSION[$settings['session_prefix'].'page'] > 0) ? '&amp;page='.$_SESSION[$settings['session_prefix'].'page'] : '';
96 $cat = ($_SESSION[$settings['session_prefix'].'category'] > 0) ? '&amp;category='.intval($_SESSION[$settings['session_prefix'].'category']) : '';
97 $subnav_2 = '';
98 if (isset($_SESSION[$settings['session_prefix'].'user_id']))
100 $url = 'index.php?update=1'. $pagination.$cat;
101 $class = 'update-postings';
102 $title = outputLangDebugInAttributes($lang['update_time_linktitle']);
103 $linktext = $lang['update_time_linkname'];
104 $subnav_2 .= outputSingleLink($url, $linktext, $title, $class);
106 if ($settings['thread_view'] == 1)
108 $url = 'forum.php?view=thread';
109 $url .= $cat;
110 $class = 'thread-view';
111 $title = outputLangDebugInAttributes($lang['thread_view_linktitle']);
112 $linktext = $lang['thread_view_linkname'];
113 $subnav_2 .= outputSingleLink($url, $linktext, $title, $class);
115 if ($settings['mix_view']==1)
117 $url = 'mix.php?view=mix';
118 $url .= $cat;
119 $class = 'mix-view';
120 $title = outputLangDebugInAttributes($lang['mix_view_linktitle']);
121 $linktext = $lang['mix_view_linkname'];
122 $subnav_2 .= outputSingleLink($url, $linktext, $title, $class);
124 $subnav_2 .= nav($_SESSION[$settings['session_prefix'].'page'], (int)$settings['topics_per_page'], $thread_count, $_SESSION[$settings['session_prefix'].'order'], $_SESSION[$settings['session_prefix'].'descasc'], $_SESSION[$settings['session_prefix'].'category']);
125 $subnav_2 .= outputCategoriesList($categories, $_SESSION[$settings['session_prefix'].'category']);
127 parse_template();
128 echo $header;
129 echo outputDebugSession();
131 if ($thread_count > 0 && isset($threadsResult))
133 $currDescAsc = strtolower($_SESSION[$settings['session_prefix'].'descasc']);
134 echo '<table class="normaltab">'."\n";
135 echo '<tr class="titlerow">'."\n";
136 echo '<th><a href="board.php?order=subject&amp;descasc=';
137 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "ASC"
138 && $_SESSION[$settings['session_prefix'].'order'] == "subject") ? 'DESC' : 'ASC';
139 echo $cat;
140 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_subject_headline'].'</a>';
141 if ($_SESSION[$settings['session_prefix'].'order'] == "subject")
143 echo outputImageDescAsc($currDescAsc);
145 echo '</th>'."\n";
146 if ($categories !== false
147 && $_SESSION[$settings['session_prefix'].'category'] == 0)
149 echo '<th><a href="board.php?order=category&amp;descasc=';
150 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "ASC"
151 && $_SESSION[$settings['session_prefix'].'order'] == "category") ? 'DESC' : 'ASC';
152 echo $cat;
153 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_category_headline'].'</a>';
154 if ($_SESSION[$settings['session_prefix'].'order'] == "category")
156 echo outputImageDescAsc($currDescAsc);
158 echo '</th>'."\n";
160 echo '<th><a href="board.php?order=name&amp;descasc=';
161 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "ASC"
162 && $_SESSION[$settings['session_prefix'].'order'] == "name") ? 'DESC' : 'ASC';
163 echo $cat;
164 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_author_headline'].'</a>'."\n";
165 if ($_SESSION[$settings['session_prefix'].'order'] == "name")
167 echo outputImageDescAsc($currDescAsc);
169 echo '</th>'."\n";
170 echo '<th><a href="board.php?order=time&amp;descasc=';
171 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "DESC"
172 && $_SESSION[$settings['session_prefix'].'order'] == "time") ? "ASC" : "DESC";
173 echo $cat;
174 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_date_headline'].'</a>'."\n";
175 if ($_SESSION[$settings['session_prefix'].'order'] == "time")
177 echo outputImageDescAsc($currDescAsc);
179 echo '</th>'."\n";
180 echo '<th>'.$lang['board_answers_headline'].'</th>'."\n";
181 echo '<th><a href="board.php?order=last_answer&amp;descasc=';
182 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "DESC"
183 && $_SESSION[$settings['session_prefix'].'order'] == "last_answer") ? "ASC" : "DESC";
184 echo $cat;
185 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_last_answer_headline'].'</a>'."\n";
186 if ($_SESSION[$settings['session_prefix'].'order'] == "last_answer")
188 echo outputImageDescAsc($currDescAsc);
190 echo '</th>'."\n";
191 if (isset($settings['count_views']) && $settings['count_views'] == 1)
193 echo '<th>'.$lang['views_headline'].'</th>';
195 if (isset($_SESSION[$settings['session_prefix'].'user_type'])
196 && $_SESSION[$settings['session_prefix'].'user_type'] == "admin")
198 echo '<th>&nbsp;</th>'."\n";
200 echo '</tr>';
202 $i=0;
203 while ($zeile = mysql_fetch_assoc($threadsResult))
205 # count replies:
206 $answers_count = outputGetReplies($zeile["tid"], $connid);
208 # data for link to last reply:
209 if ($settings['last_reply_link'] == 1 or $settings['last_reply_name'] == 1)
211 $last_answer = outputGetLastReply($zeile["tid"], $connid);
214 # highlight user, mods and admins:
215 if (($settings['admin_mod_highlight'] == 1
216 or $settings['user-highlight'] == 1)
217 && $zeile["posters_id"] > 0)
219 $mark = outputStatusMark($mark, $zeile['user_type'], $connid);
221 $rowClass = ($i % 2 == 0) ? "a" : "b";
222 echo '<tr class="'.$rowClass.'">'."\n";
223 echo '<td>'."\n"; # start: subject
224 echo '<a class="';
225 if ((isset($_SESSION[$settings['session_prefix'].'newtime'])
226 && $_SESSION[$settings['session_prefix'].'newtime'] < $zeile["last_answer"])
227 || (($zeile["pid"]==0)
228 && empty($_SESSION[$settings['session_prefix'].'newtime'])
229 && $zeile["last_answer"] > $last_visit))
231 echo 'threadnew';
233 else
235 echo 'thread';
237 echo '" href="board_entry.php?id='.$zeile["tid"].'">';
238 echo htmlspecialchars($zeile["subject"]).'</a>'."\n";
239 # show sign for fixed threads
240 if ($zeile["fixed"] == 1)
242 echo ' <img src="img/fixed.png" width="9" height="9" title="';
243 echo outputLangDebugInAttributes($lang['fixed']).'" alt="*" />';
245 if ($settings['all_views_direct'] == 1)
247 echo ' <span class="small">';
248 if ($settings['thread_view']==1)
250 echo '<a href="forum_entry.php?id='.$zeile["tid"].$cat.'">';
251 echo '<img src="img/thread_d.png" alt="[Thread]" title="';
252 echo outputLangDebugInAttributes($lang['open_in_thread_linktitle']).'" width="12" height="9" /></a>';
254 if ($settings['mix_view'] == 1)
256 echo '<a href="mix_entry.php?id='.$zeile["tid"].$cat.'">';
257 echo '<img src="img/mix_d.png" alt="[Mix]" title="';
258 echo outputLangDebugInAttributes($lang['open_in_mix_linktitle']).'" width="12" height="9" /></a>';
260 echo "</span>";
262 echo '</td>'."\n"; # end: subject
263 if ($categories!=false
264 && $_SESSION[$settings['session_prefix'].'category'] == 0)
266 echo '<td class="info">'."\n"; # start: categories (if in use)
267 if (isset($categories[$zeile["category"]]) && $categories[$zeile["category"]]!='')
269 echo '<a title="'.str_replace("[category]", $categories[$zeile["category"]], outputLangDebugInAttributes($lang['choose_category_linktitle']));
270 if (isset($category_accession[$zeile["category"]])
271 && $category_accession[$zeile["category"]] == 2)
273 echo " ".outputLangDebugInAttributes($lang['admin_mod_category']);
275 else if (isset($category_accession[$zeile["category"]])
276 && $category_accession[$zeile["category"]] == 1)
278 echo " ".outputLangDebugInAttributes($lang['registered_users_category']);
280 echo '" href="board.php?category='.$zeile["category"].'"><span class="';
281 if (isset($category_accession[$zeile["category"]])
282 && $category_accession[$zeile["category"]] == 2)
284 echo "category-adminmod-b";
286 elseif (isset($category_accession[$zeile["category"]])
287 && $category_accession[$zeile["category"]] == 1)
289 echo "category-regusers-b";
291 else
293 echo "category-b";
295 echo '">'.$categories[$zeile["category"]].'</span></a>';
297 else
299 echo "&nbsp;";
301 echo '</td>'."\n"; # end: categories
303 echo '<td class="info">'."\n"; # start: authors names
304 if (isset($_SESSION[$settings['session_prefix'].'user_id']) && $zeile["posters_id"] > 0)
306 $sult = str_replace("[name]", htmlspecialchars($zeile["name"]), outputLangDebugInAttributes($lang['show_userdata_linktitle']));
307 echo '<a href="user.php?id='.$zeile["posters_id"].'" title="'.$sult.'">';
309 echo outputAuthorsName($zeile["name"], $mark, $zeile["posters_id"]);
310 if (isset($_SESSION[$settings['session_prefix'].'user_id']) && $zeile["posters_id"] > 0)
312 echo '</a>';
314 echo '</td>'."\n"; # end: authors names
315 echo '<td class="info">'.$zeile["Uhrzeit"].'</td>'."\n";
316 echo '<td class="number-cell">'.$answers_count.'</td>'."\n";
317 echo '<td class="info">'; # start: last reply
318 if ($answers_count > 0)
320 if ($settings['last_reply_link']==1)
322 echo '<a href="board_entry.php?id='.$zeile["tid"].'&amp;be_page=';
323 echo (ceil($answers_count / $settings['answers_per_topic'])-1).'&amp;page='.$_SESSION[$settings['session_prefix'].'page'];
324 echo ($_SESSION[$settings['session_prefix'].'$category'] > 0) ? '&amp;category='.$_SESSION[$settings['session_prefix'].'category'] : '';
325 echo '&amp;order='. $_SESSION[$settings['session_prefix'].'order'] .'&amp;descasc='.$_SESSION[$settings['session_prefix'].'descasc'] .'#p'.$last_answer['id'];
326 echo '" title="'.str_replace("[name]", $last_answer['name'], outputLangDebugInAttributes($lang['last_reply_lt'])).'">';
328 echo $zeile["la_Uhrzeit"];
329 if ($settings['last_reply_name'] == 1)
331 echo (!empty($last_answer['name'])) ? ' ('.$last_answer['name'].')' : '';
333 if ($settings['last_reply_link']==1)
335 echo '</a>';
338 else
340 echo "&nbsp;";
342 echo '</td>'."\n"; # end: last reply
343 if ($settings['count_views'] == 1)
345 # number of views
346 echo '<td class="number-cell">'.$zeile['views'].'</td>'."\n";
348 if (isset($_SESSION[$settings['session_prefix'].'user_type'])
349 && $_SESSION[$settings['session_prefix'].'user_type'] == "admin")
351 echo '<td><a href="admin.php?mark='.$zeile["tid"].'&amp;refer=';
352 echo basename($_SERVER["SCRIPT_NAME"]).'&amp;page='.$_SESSION[$settings['session_prefix'].'page'];
353 echo ($_SESSION[$settings['session_prefix'].'category'] > 0) ? '&amp;category='.$_SESSION[$settings['session_prefix'].'category'] : '';
354 echo '&amp;order='.$_SESSION[$settings['session_prefix'].'order'].'">';
355 if ($zeile['marked']==1)
357 echo '<img src="img/marked.png" alt="[x]" width="9" height="9" title="'.outputLangDebugInAttributes($lang['unmark_linktitle']).'" />';
359 else
361 echo '<img src="img/mark.png" alt="[-]" title="'.outputLangDebugInAttributes($lang['mark_linktitle']).'" width="9" height="9" />';
363 echo '</a></td>'."\n";
365 echo '</tr>';
366 $i++;
367 } # End: while ()
368 echo "\n".'</table>'."\n";
369 mysql_free_result($threadsResult);
370 echo outputManipulateMarked('board');
371 } # End: if ($thread_count > 0 && isset($result))
372 else
374 # import posting template
375 $output = file_get_contents('data/templates/locked.gen.html');
376 $output = str_replace('{locked_hl}', $lang['caution'], $output);
377 $langTemp = ($_SESSION[$settings['session_prefix'].'category']!=0) ? $lang['no_messages_in_category'] : $lang['no_messages'];
378 $output = str_replace('{locked_txt}', $langTemp, $output);
379 echo $output;
381 echo $footer;
383 else
385 header("location: ".$settings['forum_address']."login.php?msg=noaccess");
386 die("<a href=\"login.php?msg=noaccess\">further...</a>");