Codechange: Klassen im Tabellenkopf eingefügt und via CSS dazugehörige Breitenangaben...
[wmmkf.git] / mix_entry.php
blob51d0587f8bdd2999869da0a08d33be14c991553c
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 function thread($id, $aktuellerEintrag = 0, $tiefe = 0) {
27 global $settings, $connid, $lang, $db_settings, $parent_array, $child_array, $user_delete, $time_difference, $categories, $mark, $sPosting;
29 $singlePostingQuery = "SELECT
30 id,
31 tid,
32 pid,
33 user_id,
34 DATE_FORMAT(time + INTERVAL ".$time_difference." HOUR, '".$lang['time_format_sql']."') AS posting_time,
35 UNIX_TIMESTAMP(time) AS time,
36 UNIX_TIMESTAMP(edited + INTERVAL ".$time_difference." HOUR) AS e_time,
37 UNIX_TIMESTAMP(edited - INTERVAL ".$settings['edit_delay']." MINUTE) AS edited_diff,
38 edited_by,
39 name,
40 email,
41 subject,
42 hp,
43 place,
44 text,
45 category,
46 show_signature,
47 locked,
48 INET_NTOA(ip_addr) AS ip_address
49 FROM ".$db_settings['forum_table']."
50 WHERE id = '".$parent_array[$id]["id"]."'
51 ORDER BY time ASC";
52 $posting_result = mysql_query($singlePostingQuery, $connid);
53 if(!$posting_result) die($lang['db_error']);
54 $entrydata = mysql_fetch_assoc($posting_result);
55 mysql_free_result($posting_result);
57 if ($entrydata["user_id"] > 0)
59 $userdata_result = mysql_query("SELECT user_name, user_type, user_email, hide_email, user_hp, user_place, signature FROM ". $db_settings['userdata_table'] ." WHERE user_id = '". $entrydata["user_id"] ."'", $connid);
60 if (!$userdata_result) die($lang['db_error']);
61 $userdata = mysql_fetch_assoc($userdata_result);
62 mysql_free_result($userdata_result);
63 $entrydata["email"] = $userdata["user_email"];
64 $entrydata["hide_email"] = $userdata["hide_email"];
65 $entrydata["place"] = $userdata["user_place"];
66 $entrydata["hp"] = $userdata["user_hp"];
67 $mark = outputStatusMark($mark, $userdata["user_type"], $connid);
68 if ($entrydata["show_signature"]==1)
70 $signature = $userdata["signature"];
74 # Posting heraussuchen, auf das geantwortet wurde:
75 $result_a = mysql_query("SELECT name FROM ". $db_settings['forum_table'] ." WHERE id = ". $parent_array[$id]["pid"], $connid);
76 $posting_a = mysql_fetch_assoc($result_a);
77 mysql_free_result($result_a);
79 $opener = ($entrydata['pid'] == 0) ? 'opener' : '';
80 $entrydata['answer'] = $posting_a['name'];
82 $pHeadline = htmlspecialchars($entrydata["subject"]);
83 if (isset($categories[$entrydata["category"]])
84 && !empty($categories[$entrydata["category"]])
85 && $entrydata["pid"]==0)
87 $pHeadline .= '&nbsp;<span class="category">('. $categories[$entrydata["category"]] .')</span>';
89 if ($entrydata['locked'] == 0)
91 if ($settings['entries_by_users_only'] == 0
92 or ($settings['entries_by_users_only'] == 1
93 and isset($_SESSION[$settings['session_prefix'].'user_name'])))
95 $answerlink = '<a class="textlink" href="posting.php?id='. $entrydata["id"] .'"';
96 $answerlink .= ' title="'.outputLangDebugInAttributes($lang['board_answer_linktitle']).'">';
97 $answerlink .= $lang['board_answer_linkname'].'</a>';
100 else
102 if ($entrydata['pid']==0)
104 $answerlink = '<span class="xsmall"><img src="img/lock.png" alt="" width="12" height="12" />';
105 $answerlink = $lang['thread_locked'].'</span>';
107 else
109 $answerlink = "&nbsp;";
112 $ftext = ($entrydata["text"]=="") ? $lang['no_text'] : outputPreparePosting($entrydata["text"]);
113 $signature = (isset($signature) && $signature != "") ? $signature = '<div class="signature">'.outputPreparePosting($settings['signature_separator']."\n".$signature, 'signature').'</div>'."\n" : '';
114 # generate HTML source code of posting
115 $posting = $sPosting;
116 $posting = str_replace('{postingID}', 'p'.$entrydata['id'], $posting);
117 $posting = str_replace('{postingheadline}', $pHeadline, $posting);
118 $posting = str_replace('{authorinfo}', outputAuthorInfo($mark, $entrydata, $page, $order, 'mix', $category), $posting);
119 $posting = str_replace('{posting}', $ftext, $posting);
120 $posting = str_replace('{signature}', $signature, $posting);
121 $posting = str_replace('{answer-locked}', $answerlink, $posting);
122 $posting = str_replace('{editmenu}', outputPostingEditMenu($entrydata, 'mix', $opener), $posting);
124 echo '<div id="p'. intval($entrydata["id"]) .'" class="mixdivl" style="margin-left: ';
125 echo ($tiefe==0 or $tiefe >= ($settings['max_thread_indent_mix_topic']/$settings['thread_indent_mix_topic'])) ? "0" : $settings['thread_indent_mix_topic'];
126 echo 'px;">'."\n";
127 echo $posting;
128 unset($posting);
130 if (isset($child_array[$id]) && is_array($child_array[$id]))
132 foreach ($child_array[$id] as $kind)
134 thread($kind, $aktuellerEintrag, $tiefe+1);
137 echo '</div>'."\n";
138 } # End: thread
140 if (!isset($_SESSION[$settings['session_prefix'].'user_id'])
141 && isset($_COOKIE['auto_login'])
142 && isset($settings['autologin'])
143 && $settings['autologin'] == 1)
145 $id = isset($_GET['id']) ? 'id='. intval($_GET['id']) : '';
146 if (!empty($id))
148 $lid = '&'.$id;
149 $did = '&amp;'.$id;
151 header("location: ".$settings['forum_address']."login.php?referer=mix_entry.php".$lid);
152 die("<a href=\"login.php?referer=mix_entry.php".$did."\">further...</a>");
155 if ($settings['access_for_users_only'] == 1
156 && isset($_SESSION[$settings['session_prefix'].'user_name'])
157 || $settings['access_for_users_only'] != 1)
159 # deinitialise unused variables
160 unset($entrydata);
161 unset($parent_array);
162 unset($child_array);
164 if (isset($_GET['id']))
166 # Wenn $id übergeben wurde ...
167 $id = intval($_GET['id']); # ... $id erst mal zu einem Integer machen ...
168 if ($id > 0) # ... und schauen ob es größer als 0 ist ...
170 $result = mysql_query("SELECT tid, pid, subject, category FROM ".$db_settings['forum_table']." WHERE id = ".$id, $connid);
171 if (!$result) die($lang['db_error']);
172 # is an entry with this id present?
173 if (mysql_num_rows($result) > 0)
175 # Und ggf. aus der Datenbank holen
176 $entrydata = mysql_fetch_assoc($result);
178 # Look if id correct:
179 if ($entrydata['pid'] != 0)
181 # if not:
182 header("location: ".$settings['forum_address']."mix_entry.php?id=". intval($entrydata['tid']) ."#p". intval($id));
185 # is this category of this posting accessible by user?
186 if (!(isset($_SESSION[$settings['session_prefix'].'user_type'])
187 && $_SESSION[$settings['session_prefix'].'user_type'] == "admin"))
189 if (is_array($category_ids) && !in_array($entrydata['category'], $category_ids))
191 header("location: ".$settings['forum_address']."mix.php");
192 die();
196 # count views:
197 if (isset($settings['count_views'])
198 && $settings['count_views'] == 1)
200 mysql_query("UPDATE ". $db_settings['forum_table'] ." SET time=time, last_answer=last_answer, edited=edited, views=views+1 WHERE tid=". intval($id), $connid);
206 if (!isset($entrydata))
208 header("Location: ".$settings['forum_address']."mix.php");
209 exit();
212 $thread = $entrydata["tid"];
213 $result = mysql_query("SELECT id, pid FROM ". $db_settings['forum_table'] ." WHERE tid = ". intval($thread) ." ORDER BY time ASC", $connid);
214 if (!$result) die($lang['db_error']);
216 // Ergebnisse einlesen
217 while ($tmp = mysql_fetch_assoc($result))
218 { // Ergebnis holen
219 $parent_array[$tmp["id"]] = $tmp; // Ergebnis im Array ablegen
220 $child_array[$tmp["pid"]][] = $tmp["id"]; // Vorwärtsbezüge konstruieren
222 mysql_free_result($result); // Aufräumen
224 $wo = $entrydata["subject"];
225 $subnav_1 = '<a class="textlink" href="mix.php">';
226 $subnav_1 .= $lang['back_to_overview_linkname'].'</a>';
227 $subnav_2 = "";
228 if ($settings['thread_view']==1)
230 $url = 'forum_entry.php?view=thread&amp;id='.$entrydata["tid"];
231 $class = 'thread-view';
232 $title = outputLangDebugInAttributes($lang['thread_view_linktitle']);
233 $linktext = $lang['thread_view_linkname'];
234 $subnav_2 .= outputSingleLink($url, $linktext, $title, $class);
236 if ($settings['board_view']==1)
238 $url = 'board_entry.php?view=board&amp;id='.$entrydata["tid"];
239 $class = 'board-view';
240 $title = outputLangDebugInAttributes($lang['board_view_linktitle']);
241 $linktext = $lang['board_view_linkname'];
242 $subnav_2 .= outputSingleLink($url, $linktext, $title, $class);
245 parse_template();
246 # import posting template
247 $sPosting = file_get_contents('data/templates/posting.mix.html');
248 echo $header;
249 echo outputDebugSession();
250 thread($thread, $id);
251 echo $footer;
253 else
255 header("location: ".$settings['forum_address']."login.php?msg=noaccess");
256 die("<a href=\"login.php?msg=noaccess\">further...</a>");