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 $id = isset($_GET['id']) ?
'id='. intval($_GET['id']) : '';
37 header("location: ".$settings['forum_address']."login.php?referer=forum_entry.php".$lid);
38 die("<a href=\"login.php?referer=forum_entry.php".$did."\">further...</a>");
41 if ($settings['access_for_users_only'] == 1
42 && isset($_SESSION[$settings['session_prefix'].'user_name'])
43 ||
$settings['access_for_users_only'] != 1)
49 if ($_SESSION[$settings['session_prefix'].'order'] != "time"
50 && $_SESSION[$settings['session_prefix'].'order'] !="last_answer")
52 $threadOrder = "time";
56 $threadOrder = $_SESSION[$settings['session_prefix'].'order'];
63 if (isset($id) && $id > 0)
65 $postingQuery = "SELECT
70 DATE_FORMAT(time + INTERVAL ".$time_difference." HOUR, '".$lang['time_format_sql']."') AS posting_time,
71 UNIX_TIMESTAMP(time) AS time,
72 UNIX_TIMESTAMP(edited + INTERVAL ".$time_difference." HOUR) AS e_time,
73 UNIX_TIMESTAMP(edited - INTERVAL ".$settings['edit_delay']." MINUTE) AS edited_diff,
81 INET_NTOA(ip_addr) AS ip_address,
87 FROM ".$db_settings['forum_table']."
88 WHERE id = ". intval($id);
89 $result = mysql_query($postingQuery, $connid);
90 if (!$result) die($lang['db_error']);
91 if (mysql_num_rows($result) == 1)
93 $entrydata = mysql_fetch_assoc($result);
94 mysql_free_result($result);
95 # category of this posting accessible by user?
96 if (!(isset($_SESSION[$settings['session_prefix'].'user_type'])
97 && $_SESSION[$settings['session_prefix'].'user_type'] == "admin"))
99 if (is_array($category_ids) && !in_array($entrydata['category'], $category_ids))
101 header("location: ".$settings['forum_address']."forum.php");
102 # Abbruch mit Fehlermeldung ergänzen!
106 if (isset($settings['count_views'])
107 && $settings['count_views'] == 1)
109 mysql_query("UPDATE ".$db_settings['forum_table']." SET time=time, last_answer=last_answer, edited=edited, views=views+1 WHERE id=". intval($id), $connid);
112 if ($entrydata["user_id"] > 0)
114 $userDataQuery = "SELECT
122 FROM ".$db_settings['userdata_table']."
123 WHERE user_id = ". intval($entrydata["user_id"]);
124 $userdata_result = mysql_query($userDataQuery, $connid);
125 if (!$userdata_result) die($lang['db_error']);
126 $userdata = mysql_fetch_assoc($userdata_result);
127 mysql_free_result($userdata_result);
128 $entrydata["email"] = $userdata["user_email"];
129 $entrydata["hide_email"] = $userdata["hide_email"];
130 $entrydata["place"] = $userdata["user_place"];
131 $entrydata["hp"] = $userdata["user_hp"];
132 $opener = ($entrydata['pid'] == 0) ?
'opener' : '';
133 if ($userdata["user_type"] == "admin" && $settings['admin_mod_highlight'] == 1)
137 else if ($userdata["user_type"] == "mod" && $settings['admin_mod_highlight'] == 1)
141 else if ($userdata["user_type"] == "user" && $settings['user_highlight'] == 1)
145 if ($entrydata["show_signature"] == 1)
147 $signature = $userdata["signature"];
153 header("location: ".$settings['forum_address']."forum.php");
159 header("location: ".$settings['forum_address']."forum.php");
164 $Thread = $entrydata["tid"];
165 $threadQuery = "SELECT
169 user_id AS posters_id,
170 DATE_FORMAT(time + INTERVAL ".$time_difference." HOUR, '".$lang['time_format_sql']."') AS Uhrzeit,
171 UNIX_TIMESTAMP(time + INTERVAL ".$time_difference." HOUR) AS time,
172 UNIX_TIMESTAMP(last_answer + INTERVAL ".$time_difference." HOUR) AS last_answer,
180 FROM ".$db_settings['userdata_table']."
181 WHERE ".$db_settings['userdata_table'].".user_id = posters_id) AS user_type
182 FROM ".$db_settings['forum_table']."
183 WHERE tid = ". intval($entrydata["tid"])."
184 ORDER BY time ". $settings['thread_view_sorter'];
185 $result = mysql_query($threadQuery, $connid);
186 if (!$result) die($lang['db_error']);
187 while ($tmp = mysql_fetch_assoc($result))
189 $postArray[$tmp["id"]] = $tmp; // Ergebnis im Array ablegen
190 $childArray[$tmp["pid"]][] = $tmp["id"]; // Vorwärtsbezüge konstruieren
192 mysql_free_result($result);
194 $category = intval($category);
196 $wo = $entrydata["subject"];
197 $subnav_1 = '<a class="textlink" href="forum.php" title="';
198 $subnav_1 .= outputLangDebugInAttributes($lang['back_to_forum_linktitle']).'">'.$lang['back_to_forum_linkname'].'</a>';
199 $cat = ($category > 0) ?
'&category='.intval($category) : '';
201 if ($settings['board_view']==1)
203 $url = 'board_entry.php?view=board&id='.$entrydata["tid"];
204 $class = 'board-view';
205 $title = outputLangDebugInAttributes($lang['board_view_linktitle']);
206 $linktext = $lang['board_view_linkname'];
207 $subnav_2 .= outputSingleLink($url, $linktext, $title, $class);
209 if ($settings['mix_view']==1)
211 $url = 'mix_entry.php?view=mix&id='.$entrydata["tid"];
213 $title = outputLangDebugInAttributes($lang['mix_view_linktitle']);
214 $linktext = $lang['mix_view_linkname'];
215 $subnav_2 .= outputSingleLink($url, $linktext, $title, $class);
219 # import posting template
220 $posting = file_get_contents('data/templates/posting.thread.html');
221 # generate posting snippets
222 $pHeadline = htmlspecialchars($entrydata["subject"]);
223 if (isset($categories[$entrydata["category"]]) && $categories[$entrydata["category"]]!='')
225 $pHeadline .= ' <span class="category">('.$categories[$entrydata["category"]].')</span>';
227 $ftext = ($entrydata["text"]=="") ?
$lang['no_text'] : outputPreparePosting($entrydata["text"]);
228 $signature = (isset($signature) && $signature != "") ?
$signature = '<div class="signature">'.outputPreparePosting($settings['signature_separator']."\n".$signature, 'signature').'</div>'."\n" : '';
229 if ($entrydata['locked'] == 0)
231 if ($settings['entries_by_users_only'] == 0
232 or ($settings['entries_by_users_only'] == 1
233 and isset($_SESSION[$settings['session_prefix'].'user_name'])))
235 $answerlink = '<a class="textlink" href="posting.php?id='. intval($id);
236 $answerlink .= '" title="'.outputLangDebugInAttributes($lang['forum_answer_linktitle']).'">';
237 $answerlink .= $lang['forum_answer_linkname'].'</a>';
242 $answerlink = '<span class="xsmall"><img src="img/lock.png" alt="" width="12" height="12" />'.$lang['thread_locked'].'</span>';
244 # generate HTML source code of posting
245 $posting = str_replace('{postingheadline}', $pHeadline, $posting);
246 $posting = str_replace('{authorinfo}', outputAuthorInfo($mark, $entrydata, $page, $order, 'forum', $category), $posting);
247 $posting = str_replace('{posting}', $ftext, $posting);
248 $posting = str_replace('{signature}', $signature, $posting);
249 $posting = str_replace('{answer-locked}', $answerlink, $posting);
250 $posting = str_replace('{editmenu}', outputPostingEditMenu($entrydata, '', $opener), $posting);
251 $posting = str_replace('{threadheadline}', $lang['whole_thread_marking'], $posting);
252 $posting = str_replace('{thread}', outputThreads($postArray, $childArray, 'forum', 0), $posting);
254 echo outputDebugSession();
260 header("location: ".$settings['forum_address']."login.php?msg=noaccess");
261 die("<a href=\"login.php?msg=noaccess\">further...</a>");