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 ' <thead>'."\n";
139 echo ' <th><a href="mix.php?order=subject&descasc=';
140 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "ASC"
141 && $_SESSION[$settings['session_prefix'].'order'] == "subject") ?
'DESC' : 'ASC';
142 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_subject_headline'].'</a>';
143 if ($_SESSION[$settings['session_prefix'].'order'] == "subject")
145 echo outputImageDescAsc($currDescAsc);
148 if ($categories !== false
149 && $_SESSION[$settings['session_prefix'].'category'] == 0)
151 echo ' <th><a href="mix.php?order=category&descasc=';
152 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "ASC"
153 && $_SESSION[$settings['session_prefix'].'order'] == "category") ?
'DESC' : 'ASC';
154 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_category_headline'].'</a>';
155 if ($_SESSION[$settings['session_prefix'].'order'] == "category")
157 echo outputImageDescAsc($currDescAsc);
161 echo ' <th><a href="mix.php?order=name&descasc=';
162 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "ASC"
163 && $_SESSION[$settings['session_prefix'].'order'] == "name") ?
'DESC' : 'ASC';
164 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_author_headline'].'</a>';
165 if ($_SESSION[$settings['session_prefix'].'order'] == "name")
167 echo outputImageDescAsc($currDescAsc);
170 echo ' <th><a href="mix.php?order=time&descasc=';
171 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "DESC"
172 && $_SESSION[$settings['session_prefix'].'order'] == "time") ?
"ASC" : "DESC";
173 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_date_headline'].'</a>';
174 if ($_SESSION[$settings['session_prefix'].'order'] == "time")
176 echo outputImageDescAsc($currDescAsc);
179 echo ' <th>'.$lang['board_answers_headline'].'</th>'."\n";
180 echo ' <th><a href="mix.php?order=last_answer&descasc=';
181 echo ($_SESSION[$settings['session_prefix'].'descasc'] == "DESC"
182 && $_SESSION[$settings['session_prefix'].'order'] == "last_answer") ?
'ASC' : 'DESC';
183 echo '" title="'.outputLangDebugInAttributes($lang['order_linktitle']).'">'.$lang['board_last_answer_headline'].'</a>';
184 if ($_SESSION[$settings['session_prefix'].'order'] == "last_answer")
186 echo outputImageDescAsc($currDescAsc);
189 if (isset($settings['count_views']) && $settings['count_views'] == 1)
191 echo ' <th>'.$lang['views_headline'].'</th>'."\n";
193 if (isset($_SESSION[$settings['session_prefix'].'user_type'])
194 && $_SESSION[$settings['session_prefix'].'user_type'] == "admin")
196 echo ' <th> </th>'."\n";
199 echo ' </thead>'."\n".' <tbody>'."\n".' ';
201 while ($zeile = mysql_fetch_assoc($threadsResult))
203 # read entries of thread
204 $threadCompleteQuery = "SELECT
209 DATE_FORMAT(time + INTERVAL ".$time_difference." HOUR, '".$lang['time_format_sql']."') AS Uhrzeit,
216 FROM ".$db_settings['forum_table']."
217 WHERE tid = ".$zeile["tid"]."
219 $rawresult = dbaseAskDatabase($threadCompleteQuery, $connid);
220 # Ergebnisse einlesen:
221 foreach ($rawresult as $tmp)
223 $postArray[$tmp["id"]] = $tmp; // Ergebnis im Array ablegen
224 $childArray[$tmp["pid"]][] = $tmp["id"]; // Vorwärtsbezüge konstruieren
227 $answers_count = outputGetReplies($zeile["tid"], $connid);
229 # data for link to last reply:
230 if ($settings['last_reply_link'] == 1)
232 $last_answer = outputGetLastReply($zeile["tid"], $connid);
234 # generate output of thread lists
235 # highlight user, mods and admins:
236 if (!empty($zeile['user_type'])
237 and ($settings['admin_mod_highlight'] == 1
238 or $settings['user-highlight'] == 1))
240 $markA = outputStatusMark($mark, $zeile['user_type'], $connid);
243 echo ' <td>'.outputThreads($postArray, $childArray, 'mix', 4).' </td>'."\n";
244 if ($categories !== false
245 && $_SESSION[$settings['session_prefix'].'category'] == 0)
247 echo ' <td class="info">'; #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">';
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);
349 echo "\n".' </tbody>'."\n".'</table>'."\n";
350 mysql_free_result($threadsResult);
351 echo outputManipulateMarked('mix');
355 # import posting template
356 $output = file_get_contents('data/templates/locked.gen.html');
357 $output = str_replace('{locked_hl}', $lang['caution'], $output);
358 $langTemp = ($category!=0) ?
$lang['no_messages_in_category'] : $lang['no_messages'];
359 $output = str_replace('{locked_txt}', $langTemp, $output);
366 header("location: ".$settings['forum_address']."login.php?msg=noaccess");
367 die("<a href=\"login.php?msg=noaccess\">further...</a>");