2 ###############################################################################
4 # Copyright (C) 2005 Alex #
5 # http://www.mylittlehomepage.net/ #
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. #
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. #
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 ###############################################################################
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=mix.php");
32 die("<a href=\"login.php?referer=mix.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","mix",time()+
(3600*24*30));
46 $ul = $_SESSION[$settings['session_prefix'].'page'] * $settings['topics_per_page'];
48 # Variablen korrekt (de)initialisieren
52 # use next results somewhere around line 280
54 # no categories defined
55 if ($categories === false)
57 $threadsQueryWhere = '';
59 # there are categories and all categories should be shown
60 else if (is_array($categories)
61 && $_SESSION[$settings['session_prefix'].'category'] == 0)
63 $threadsQueryWhere = " AND category IN (".$category_ids_query.")";
65 # there are categories and one category should be shown
66 else if (is_array($categories)
67 && $_SESSION[$settings['session_prefix'].'category'] != 0
68 && in_array($_SESSION[$settings['session_prefix'].'category'], $category_ids))
70 $threadsQueryWhere = " AND category = '". mysql_real_escape_string($_SESSION[$settings['session_prefix'].'category']) ."'";
72 $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);
73 list($thread_count) = mysql_fetch_row($pid_result);
74 mysql_free_result($pid_result);
77 $threadsQuery = "SELECT
79 t1.user_id AS posters_id,
80 DATE_FORMAT(time + INTERVAL ".$time_difference." HOUR, '".$lang['time_format_sql']."') AS Uhrzeit,
81 DATE_FORMAT(last_answer + INTERVAL ".$time_difference." HOUR, '".$lang['time_format_sql']."') AS la_Uhrzeit,
82 UNIX_TIMESTAMP(last_answer) AS last_answer,
88 FROM ".$db_settings['userdata_table']."
89 WHERE ".$db_settings['userdata_table'].".user_id = posters_id) AS user_type
90 FROM ".$db_settings['forum_table']." AS t1
91 WHERE pid = 0".$threadsQueryWhere."
92 ORDER BY fixed DESC, ".$_SESSION[$settings['session_prefix'].'order']." ".$_SESSION[$settings['session_prefix'].'descasc']."
93 LIMIT ".$ul.", ".$settings['topics_per_page'];
94 $threadsResult = mysql_query($threadsQuery, $connid);
95 if (!$threadsResult) die($lang['db_error']);
97 $subnav_1 = outputPostingLink($_SESSION[$settings['session_prefix'].'category'],"mix");
98 $pagination = ($_SESSION[$settings['session_prefix'].'page'] > 0) ?
'&page='.$_SESSION[$settings['session_prefix'].'page'] : '';
99 $cat = ($_SESSION[$settings['session_prefix'].'category'] > 0) ?
'&category='.intval($_SESSION[$settings['session_prefix'].'category']) : '';
101 if (isset($_SESSION[$settings['session_prefix'].'user_id']))
103 $url = 'index.php?update=1'. $pagination.$cat;
104 $class = 'update-postings';
105 $title = outputLangDebugInAttributes($lang['update_time_linktitle']);
106 $linktext = $lang['update_time_linkname'];
107 $subnav_2 .= outputSingleLink($url, $linktext, $title, $class);
109 if ($settings['thread_view'] == 1)
111 $url = 'forum.php?view=thread';
112 $class = 'thread-view';
113 $title = outputLangDebugInAttributes($lang['thread_view_linktitle']);
114 $linktext = $lang['thread_view_linkname'];
115 $subnav_2 .= outputSingleLink($url, $linktext, $title, $class);
117 if ($settings['board_view']==1)
119 $url = 'board.php?view=board';
120 $class = 'board-view';
121 $title = outputLangDebugInAttributes($lang['board_view_linktitle']);
122 $linktext = $lang['board_view_linkname'];
123 $subnav_2 .= outputSingleLink($url, $linktext, $title, $class);
125 $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']);
126 $categories = get_categories();
127 $subnav_2 .= outputCategoriesList($categories, $_SESSION[$settings['session_prefix'].'category']);
131 echo outputDebugSession();
133 if ($thread_count > 0 && isset($threadsResult))
135 $currDescAsc = strtolower($_SESSION[$settings['session_prefix'].'descasc']);
136 echo '<table class="normaltab">'."\n";
137 echo '<tr class="titlerow">'."\n";
138 echo '<th><a href="mix.php?order=subject&descasc=';
139 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "ASC"
140 && $_SESSION[$settings['session_prefix'].'order'] == "subject") ?
'DESC' : 'ASC';
141 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_subject_headline'].'</a>';
142 if ($_SESSION[$settings['session_prefix'].'order'] == "subject")
144 echo outputImageDescAsc($currDescAsc);
147 if ($categories !== false
148 && $_SESSION[$settings['session_prefix'].'category'] == 0)
150 echo '<th><a href="mix.php?order=category&descasc=';
151 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "ASC"
152 && $_SESSION[$settings['session_prefix'].'order'] == "category") ?
'DESC' : 'ASC';
153 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_category_headline'].'</a>';
154 if ($_SESSION[$settings['session_prefix'].'order'] == "category")
156 echo outputImageDescAsc($currDescAsc);
160 echo '<th><a href="mix.php?order=name&descasc=';
161 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "ASC"
162 && $_SESSION[$settings['session_prefix'].'order'] == "name") ?
'DESC' : 'ASC';
163 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_author_headline'].'</a>';
164 if ($_SESSION[$settings['session_prefix'].'order'] == "name")
166 echo outputImageDescAsc($currDescAsc);
169 echo '<th><a href="mix.php?order=time&descasc=';
170 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "DESC"
171 && $_SESSION[$settings['session_prefix'].'order'] == "time") ?
"ASC" : "DESC";
172 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_date_headline'].'</a>';
173 if ($_SESSION[$settings['session_prefix'].'order'] == "time")
175 echo outputImageDescAsc($currDescAsc);
178 echo '<th>'.$lang['board_answers_headline'].'</th>'."\n";
179 echo '<th><a href="mix.php?order=last_answer&descasc=';
180 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "DESC"
181 && $_SESSION[$settings['session_prefix'].'order'] == "last_answer") ?
'ASC' : 'DESC';
182 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_last_answer_headline'].'</a>';
183 if ($_SESSION[$settings['session_prefix'].'order'] == "last_answer")
185 echo outputImageDescAsc($currDescAsc);
188 if (isset($settings['count_views']) && $settings['count_views'] == 1)
190 echo '<th>'.$lang['views_headline'].'</th>'."\n";
192 if (isset($_SESSION[$settings['session_prefix'].'user_type'])
193 && $_SESSION[$settings['session_prefix'].'user_type'] == "admin")
195 echo '<th> </th>'."\n";
200 while ($zeile = mysql_fetch_assoc($threadsResult))
202 # read entries of thread
203 $threadCompleteQuery = "SELECT
208 DATE_FORMAT(time + INTERVAL ".$time_difference." HOUR, '".$lang['time_format_sql']."') AS Uhrzeit,
215 FROM ".$db_settings['forum_table']."
216 WHERE tid = ".$zeile["tid"]."
218 $rawresult = dbaseAskDatabase($threadCompleteQuery, $connid);
219 # Ergebnisse einlesen:
220 foreach ($rawresult as $tmp)
222 $postArray[$tmp["id"]] = $tmp; // Ergebnis im Array ablegen
223 $childArray[$tmp["pid"]][] = $tmp["id"]; // Vorwärtsbezüge konstruieren
226 $answers_count = outputGetReplies($zeile["tid"], $connid);
228 # data for link to last reply:
229 if ($settings['last_reply_link'] == 1)
231 $last_answer = outputGetLastReply($zeile["tid"], $connid);
233 # generate output of thread lists
234 # highlight user, mods and admins:
235 if (!empty($zeile['user_type'])
236 and ($settings['admin_mod_highlight'] == 1
237 or $settings['user-highlight'] == 1))
239 $markA = outputStatusMark($mark, $zeile['user_type'], $connid);
241 $rowClass = ($i %
2 == 0) ?
"a" : "b";
242 echo '<tr class="'.$rowClass.'">'."\n";
243 echo ' <td>'.outputThreads($postArray, $childArray, 'mix', 2).'</td>'."\n";
244 if ($categories !== false
245 && $_SESSION[$settings['session_prefix'].'category'] == 0)
247 echo '<td class="info">'."\n"; #categories
248 if (isset($categories[$zeile["category"]]) && $categories[$zeile["category"]]!='')
250 echo '<a title="'.str_replace("[category]", $categories[$zeile["category"]], outputLangDebugInAttributes($lang['choose_category_linktitle']));
251 if (isset($category_accession[$zeile["category"]])
252 && $category_accession[$zeile["category"]] == 2)
254 echo " ".outputLangDebugInAttributes($lang['admin_mod_category']);
256 else if (isset($category_accession[$zeile["category"]])
257 && $category_accession[$zeile["category"]] == 1)
259 echo " ".outputLangDebugInAttributes($lang['registered_users_category']);
261 echo '" href="mix.php?category='.$zeile["category"].'"><span class="';
262 if (isset($category_accession[$zeile["category"]])
263 && $category_accession[$zeile["category"]] == 2)
265 echo "category-adminmod-b";
267 else if (isset($category_accession[$zeile["category"]])
268 && $category_accession[$zeile["category"]] == 1)
270 echo "category-regusers-b";
276 echo '">'.$categories[$zeile["category"]].'</span></a>';
285 echo '<td class="info">'."\n";
286 if (isset($_SESSION[$settings['session_prefix'].'user_id']) && $zeile["user_id"] > 0)
288 $sult = str_replace("[name]", htmlspecialchars($zeile["name"]), outputLangDebugInAttributes($lang['show_userdata_linktitle']));
289 echo '<a href="user.php?id='.$zeile["user_id"].'" title="'.$sult.'">';
291 echo outputAuthorsName($zeile["name"], $markA, $zeile["posters_id"]);
292 if (isset($_SESSION[$settings['session_prefix'].'user_id']) && $zeile["user_id"] > 0)
298 echo '<td class="info">'.$zeile["Uhrzeit"].'</td>'."\n";
300 echo '<td class="number-cell">'.$answers_count.'</td>'."\n";
302 echo '<td class="info">';
303 if ($answers_count > 0)
305 if ($settings['last_reply_link']==1)
307 echo '<a href="mix_entry.php?id='.$zeile["tid"].'#p'.$last_answer['id'].'" title="';
308 echo str_replace("[name]", $last_answer['name'], outputLangDebugInAttributes($lang['last_reply_lt'])).'">';
310 echo $zeile["la_Uhrzeit"];
311 if ($settings['last_reply_link']==1)
321 if (isset($settings['count_views']) && $settings['count_views'] == 1)
324 echo '<td class="number-cell">'.$zeile['views'].'</td>'."\n";
326 if (isset($_SESSION[$settings['session_prefix'].'user_type'])
327 && $_SESSION[$settings['session_prefix'].'user_type'] == "admin")
330 echo '<td><a href="admin.php?mark='.$zeile["tid"].'&refer=';
331 echo basename($_SERVER["SCRIPT_NAME"]).'&page='.$page;
332 echo ($category > 0) ?
'&category='.$category : '';
333 echo '&order='.$order.'">';
334 if ($zeile['marked']==1)
336 echo '<img src="img/marked.png" alt="[x]" width="9" height="9"';
337 echo ' title="'.outputLangDebugInAttributes($lang['unmark_linktitle']).'" />';
341 echo '<img src="img/mark.png" alt="[-]" title="';
342 echo outputLangDebugInAttributes($lang['mark_linktitle']).'" width="9" height="9" />';
344 echo '</a></td>'."\n";
347 unset($rawresult, $childArray, $postArray);
350 echo "\n".'</table>'."\n";
351 mysql_free_result($threadsResult);
352 echo outputManipulateMarked('mix');
356 # import posting template
357 $output = file_get_contents('data/templates/locked.gen.html');
358 $output = str_replace('{locked_hl}', $lang['caution'], $output);
359 $langTemp = ($category!=0) ?
$lang['no_messages_in_category'] : $lang['no_messages'];
360 $output = str_replace('{locked_txt}', $langTemp, $output);
367 header("location: ".$settings['forum_address']."login.php?msg=noaccess");
368 die("<a href=\"login.php?msg=noaccess\">further...</a>");