Codechange: Gruppierung der Ausgabe der Benutzerliste, Tabellen mit <thead> und ...
[wmmkf.git] / functions.php
blobb4ada6efab0e6544bed28f02d47ed02e3c2a8e01
1 <?php
2 ###############################################################################
3 # my little forum #
4 # Copyright (C) 2005 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 #require_once("function.tab2space.php");
23 require_once('functions/funcs.db.php');
24 require_once('functions/funcs.output.php');
25 require_once('functions/funcs.processing.php');
26 require_once('data/extern/stringparser_bbcode/src/stringparser_bbcode.class.php');
29 # Entferne bei aktivem magic_quotes_gpc die Slashes in den uebergebenen Werten
30 # siehe: http://php.net/manual/en/security.magicquotes.disabling.html
32 /**
33 * disables magic_quotes from given variables of different types
35 * @param variable [$value]
36 * @return variable [$value]
37 * @since 1.7.7
38 * @link http://php.net/manual/en/security.magicquotes.disabling.html
40 function stripslashes_deep($value) {
41 $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
42 return $value;
43 } # Ende: stripslashes_deep
47 /**
48 * reads the forum settings from the database
51 function get_settings() {
52 global $lang, $connid, $db_settings;
54 $r = array();
56 $result = mysql_query("SELECT name, value FROM ".$db_settings['settings_table'], $connid);
57 if (!$result) die($lang['db_error']);
58 while ($line = mysql_fetch_assoc($result))
60 $r[$line['name']] = $line['value'];
62 mysql_free_result($result);
64 return $r;
65 } # End: get_settings
69 /**
70 * returns the list of own settings for a registred and logged user
72 * @param integer $user_id
73 * @return array $list
75 function getMyOwnSettings($user_id) {
76 global $db_settings, $connid;
78 $list = array();
80 $result = mysql_query("SELECT name, value FROM ".$db_settings['usersettings_table']." WHERE user_id = ".intval($user_id), $connid);
81 if (!$result) die($lang['db_error']);
82 while ($line = mysql_fetch_assoc($result))
84 $list[$line['name']] = $line['value'];
86 return $list;
87 } # End: getMyOwnSettings
91 /**
92 * reads the category names and ids from the database
94 * @return array $categories
95 * @return bool false
97 function get_categories() {
98 global $lang, $settings, $connid, $db_settings;
100 $count_result = mysql_query("SELECT COUNT(*) FROM ".$db_settings['category_table'], $connid);
101 list($category_count) = mysql_fetch_row($count_result);
102 mysql_free_result($count_result);
104 if ($category_count > 0)
106 if (empty($_SESSION[$settings['session_prefix'].'user_id']))
108 $categoriesQuery = "SELECT
110 category
111 FROM ".$db_settings['category_table']."
112 WHERE accession = 0
113 ORDER BY category_order ASC";
115 else if (isset($_SESSION[$settings['session_prefix'].'user_id']) && isset($_SESSION[$settings['session_prefix'].'user_type']) && $_SESSION[$settings['session_prefix'].'user_type'] == "user")
117 $categoriesQuery = "SELECT
119 category
120 FROM ".$db_settings['category_table']."
121 WHERE accession = 0 OR accession = 1
122 ORDER BY category_order ASC";
124 else if (isset($_SESSION[$settings['session_prefix'].'user_id']) && isset($_SESSION[$settings['session_prefix'].'user_type']) && ($_SESSION[$settings['session_prefix'].'user_type'] == "mod" || $_SESSION[$settings['session_prefix'].'user_type'] == "admin"))
126 $categoriesQuery = "SELECT
128 category
129 FROM ".$db_settings['category_table']."
130 WHERE accession = 0 OR accession = 1 OR accession = 2
131 ORDER BY category_order ASC";
133 $result = mysql_query($categoriesQuery, $connid);
134 if (!$result) die($lang['db_error']);
135 $categories[0]='';
136 while ($line = mysql_fetch_assoc($result))
138 $categories[$line['id']] = $line['category'];
140 mysql_free_result($result);
141 return $categories;
143 else return false;
144 } # End: get_categories
149 * reads the categories ids from the categories list
151 * @param array $categories
152 * @return array $category_ids
153 * @return bool false
155 function get_category_ids($categories) {
156 if($categories !== false)
158 while(list($key) = each($categories))
160 $category_ids[] = $key;
162 return $category_ids;
164 else return false;
165 } # End: get_categories_ids
170 * lists the access rights to the categories
172 * @return array $category_accession
173 * @return bool false
175 function category_accession() {
176 global $settings, $lang, $connid, $db_settings;
178 $result = mysql_query("SELECT id, accession FROM ".$db_settings['category_table'], $connid);
179 while ($line = mysql_fetch_assoc($result))
181 $category_accession[$line['id']] = $line['accession'];
183 mysql_free_result($result);
184 $r = isset($category_accession) ? $category_accession : false;
186 return $r;
187 } # End: category_accession
192 * page navigation for forum.php, board.php and mix.php
194 * @param integer $page
195 * @param integer $entries_per_page
196 * @param integer $entry_count
197 * @param string $order
198 * @param string $descasc
199 * @param integer $category
200 * @param string $action (optional)
201 * @return string $output
203 function nav($page, $entries_per_page, $entry_count, $order, $descasc, $category, $action="") {
204 global $lang, $select_submit_button;
206 $output = "";
207 if ($entry_count > $entries_per_page)
209 $output .= "&nbsp;";
210 $new_index_before = $page - 1;
211 $new_index_after = $page + 1;
212 $site_count = ceil($entry_count / $entries_per_page);
213 $ic = '';
214 $ic .= (isset($category) and $category > 0) ? '&amp;category='.intval($category) : '';
215 $ic .= (isset($action) && $action!="") ? '&amp;action='.$action : '';
216 $ic .= (isset($_GET['letter'])) ? '&amp;letter='.urlencode($_GET['letter']) : '';
217 if ($new_index_before >= 0)
219 $output .= '<a href="'.$_SERVER["SCRIPT_NAME"].'?page='.$new_index_before;
220 $output .= '&amp;order='.$order.'&amp;descasc='.$descasc.$ic.'">';
221 $output .= '<img src="img/prev.png" alt="&laquo;" title="';
222 $output .= strip_tags($lang['previous_page_linktitle']).'" width="12" height="9" /></a>&nbsp;';
224 # if ($new_index_before >= 0 && $new_index_after < $site_count) $output .= " ";
225 $page_count = ceil($entry_count / $entries_per_page);
226 $output .= '<form action="'.$_SERVER["SCRIPT_NAME"].'" method="get" title="';
227 $output .= strip_tags($lang['choose_page_formtitle']).'"><div class="inline-form">'."\n";
228 $output .= isset($order) ? '<input type="hidden" name="order" value="'.$order.'" />' : '';
229 $output .= isset($descasc) ? '<input type="hidden" name="descasc" value="'.$descasc.'" />' : '';
230 $output .= (isset($category) and $category > 0) ? '<input type="hidden" name="category" value="'.$category.'" />' : '';
231 $output .= (isset($action) && $action!="") ? '<input type="hidden" name="action" value="'.$action.'" />' : '';
232 $output .= (isset($_GET['letter'])) ? '<input type="hidden" name="letter" value="'.$_GET['letter'].'" />' : '';
233 $output .= '<select class="kat" size="1" name="page" onchange="this.form.submit();">'."\n";
234 $output .= '<option value="0"';
235 $output .= ($page == 0) ? ' selected="selected"' : '';
236 $output .= '>'.str_replace("[number]", "1", $lang['page_number']).'</option>'."\n";
237 for($x=$page-9; $x<$page+10; $x++)
239 if ($x > 0 && $x < $page_count)
241 $output .= '<option value="'.$x.'"';
242 $output .= ($page == $x) ? ' selected="selected"' : '';
243 $output .= '>'.str_replace("[number]", $x+1, $lang['page_number']).'</option>'."\n";
246 $output .= '</select>'."\n".'<noscript>&nbsp;<input type="image" name="" value="" src="img/submit.png" alt="&raquo;" /></noscript></div></form>'."\n";
247 if ($new_index_after < $site_count)
249 $output .= '&nbsp;<a href="'.$_SERVER["SCRIPT_NAME"]."?page=".$new_index_after;
250 $output .= '&amp;order='.$order.'&amp;descasc='.$descasc.$ic.'">';
251 $output .= '<img src="img/next.png" alt="&raquo;" title="';
252 $output .= strip_tags($lang['next_page_linktitle']).'" width="12" height="9" /></a>';
256 return $output;
257 } # End: nav
262 * amend the protocol to a given link
264 * @param string $link
265 * @return string $link
267 function amendProtocol($hp) {
269 if (substr($hp,0,7) != "http://"
270 && substr($hp,0,8) != "https://"
271 && substr($hp,0,6) != "ftp://"
272 && substr($hp,0,9) != "gopher://"
273 && substr($hp,0,7) != "news://")
275 $hp = "http://".$hp;
278 return $hp;
279 } # End: amendProtocol
284 * makes URLs clickable
286 * @param string
287 * @return string
289 function make_link($string) {
290 $string = ' '.$string;
291 $string = preg_replace_callback("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is", "shorten_link", $string);
292 $string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "\\1<a href=\"http://\\2\">\\2</a>", $string);
293 $string = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $string);
294 $string = substr($string, 1);
296 return $string;
297 } # End: make_link
302 * function to hide the links from the checkings in posting.php
304 * @param string $string
305 * @return string $string
307 function text_check_link($string) {
308 $string = ' '.$string;
309 $string = preg_replace("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is", "", $string);
310 $string = substr($string, 1);
312 return $string;
313 } # End: text_check_link
318 * replaces bb-codes in posting with HTML-source
320 * @param string $string
321 * @retrun string $string
323 function bbcode($string) {
324 global $settings;
326 $bbcode = new StringParser_BBCode ();
327 $bbcode->addFilter(STRINGPARSER_FILTER_PRE, 'convertLineBreaks');
328 $bbcode->addParser(array('block','inline','link','listitem'), 'htmlspecialchars');
329 $bbcode->addParser(array('block','inline','link','listitem'), 'nl2br');
330 $bbcode->addParser('list', 'bbcodeStripContents');
332 # codes
333 $bbcode->addCode('b', 'simple_replace', null, array ('start_tag' => '<strong>', 'end_tag' => '</strong>'), 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
334 $bbcode->addCode('i', 'simple_replace', null, array ('start_tag' => '<em>', 'end_tag' => '</em>'), 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
335 $bbcode->addCode('u', 'simple_replace', null, array ('start_tag' => '<span class="underline">', 'end_tag' => '</span>'), 'inline', array ('listitem', 'block', 'inline'), array ());
336 $bbcode->addCode('del', 'simple_replace', null, array ('start_tag' => '<del>', 'end_tag' => '</del>'), 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
337 $bbcode->addCode('ins', 'simple_replace', null, array ('start_tag' => '<ins>', 'end_tag' => '</ins>'), 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
338 $bbcode->addCode('sub', 'simple_replace', null, array ('start_tag' => '<sub>', 'end_tag' => '</sub>'), 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
339 $bbcode->addCode('sup', 'simple_replace', null, array ('start_tag' => '<sup>', 'end_tag' => '</sup>'), 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
340 $bbcode->addCode('code', 'simple_replace', null, array ('start_tag' => '<code>', 'end_tag' => '</code>'), 'inline', array ('listitem', 'block', 'inline'), array ());
341 $bbcode->addCode('url', 'usecontent?', 'bbcodeDoURL', array ('usecontent_param' => 'default'), 'link', array ('listitem', 'block', 'inline'), array ('link'));
342 $bbcode->addCode('link', 'usecontent?', 'bbcodeDoURL', array ('usecontent_param' => 'default'), 'link', array ('listitem', 'block', 'inline'), array ('link'));
344 # code flags
345 $bbcode->setCodeFlag('b', 'case_sensitive', false);
346 $bbcode->setCodeFlag('i', 'case_sensitive', false);
347 $bbcode->setCodeFlag('u', 'case_sensitive', false);
349 #$bbcode->setCodeFlag('*', 'closetag', BBCODE_CLOSETAG_OPTIONAL);
350 #$bbcode->setCodeFlag('*', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
351 #$bbcode->setCodeFlag('list', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
352 #$bbcode->setCodeFlag('list', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
353 #$bbcode->setCodeFlag('list', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
354 $bbcode->setRootParagraphHandling(true);
356 # do the parsing
357 $string = $bbcode->parse($string);
359 #$string = preg_replace("#\[link\]www\.(.+?)\[/link\]#is", "<a href=\"http://www.\\1\">www.\\1</a>", $string);
360 #$string = preg_replace_callback("#\[link\](.+?)\[/link\]#is", "shorten_link", $string);
361 #$string = preg_replace("#\[link=(.+?)\](.+?)\[/link\]#is", "<a href=\"\\1\">\\2</a>", $string);
362 #$string = preg_replace("#\[url\]www\.(.+?)\[/url\]#is", "<a href=\"http://www.\\1\">www.\\1</a>", $string);
363 #$string = preg_replace_callback("#\[url\](.+?)\[/url\]#is", "shorten_link", $string);
364 #$string = preg_replace("#\[url=(.+?)\](.+?)\[/url\]#is", "<a href=\"\\1\">\\2</a>", $string);
365 #$string = preg_replace_callback("#\[code\](.+?)\[/code\]#is", "parse_code", $string);
366 $string = preg_replace("#\[msg\](.+?)\[/msg\]#is", "<a href=\"".$_SERVER['SCRIPT_NAME']."?id=\\1\">\\1</a>", $string);
367 $string = preg_replace("#\[msg=(.+?)\](.+?)\[/msg\]#is", "<a href=\"".$_SERVER['SCRIPT_NAME']."?id=\\1\">\\2</a>", $string);
368 if ($settings['bbcode_img'] == 1)
370 $string = preg_replace("#\[img\](.+?)\[/img\]#is", "<img src=\"\\1\" alt=\"[image]\" style=\"margin: 5px 0px 5px 0px\" />", $string);
371 $string = preg_replace("#\[img\|left\](.+?)\[/img\]#is", "<img src=\"\\1\" alt=\"[image]\" style=\"float: left; margin: 0px 5px 5px 0px\" />", $string);
372 $string = preg_replace("#\[img\|right\](.+?)\[/img\]#is", "<img src=\"\\1\" alt=\"[image]\" style=\"float: right; margin: 0px 0px 5px 5px\" />", $string);
374 $string = str_replace('javascript','javascr***',$string);
376 return $string;
377 } # End: bbcode
382 * cuts the URL as link text(!) after $setting['text_word_maxlength']/2
384 * @param string $string
385 * @return string $string
387 function shorten_link($url) {
388 global $settings;
390 $t = $url;
391 if (strlen($url) > $settings['text_word_maxlength'])
392 $t = substr($url, 0, ($settings['text_word_maxlength']/2)) . "..." . substr($url, - ($settings['text_word_maxlength']-3-$settings['text_word_maxlength']/2));
394 return $t;
395 } # End: shorten_link
400 * returns the HTML code for the output of posted source code
402 * @param string $string
403 * @return string $string
405 function parse_code($string) {
406 global $view;
407 if (basename($_SERVER['PHP_SELF'])=='board_entry.php' || basename($_SERVER['PHP_SELF'])=='mix_entry.php')
409 $p_class='postingboard';
411 else if (!empty($view) and ($view=='board' or $view=='mix'))
413 $p_class='postingboard';
415 else
417 $p_class='posting';
419 $string = $string[1];
420 $string = str_replace('<br />','',$string);
421 $string = '</p>'."\n".'<pre class="'.$p_class.'"><code>'.$string.'</code></pre>'."\n".'<p class="'.$p_class.'">';
423 return $string;
424 } # End: parse_code
429 * strips bb codes for e-mail texts:
431 * @param string $string
432 * @return string $string
434 function unbbcode($string) {
435 global $settings;
437 $string = preg_replace("#\[b\](.+?)\[/b\]#is", "*\\1*", $string);
438 $string = preg_replace("#\[i\](.+?)\[/i\]#is", "/\\1/", $string);
439 $string = preg_replace("#\[u\](.+?)\[/u\]#is", "_\\1_", $string);
440 $string = preg_replace("#\[link\]www\.(.+?)\[/link\]#ise", "'http://www.'.processUrlEncode('\\1', false)", $string);
441 $string = preg_replace("#\[link\](.+?)\[/link\]#ise", "processUrlEncode('\\1')", $string);
442 $string = preg_replace("#\[link=(.+?)\](.+?)\[/link\]#ise", "'\\2 --> '.processUrlEncode('\\1')", $string);
443 $string = preg_replace("#\[url\]www\.(.+?)\[/url\]#ise", "'http://www.'.processUrlEncode('\\1', false)", $string);
444 $string = preg_replace("#\[url\](.+?)\[/url\]#ise", "processUrlEncode('\\1')", $string);
445 $string = preg_replace("#\[url=(.+?)\](.+?)\[/url\]#ise", "'\\2 --> '.processUrlEncode('\\1')", $string);
446 $string = preg_replace("#\[code\](.+?)\[/code\]#is", "\\1", $string);
447 $string = preg_replace("#\[msg\](.+?)\[/msg\]#is", "\\1", $string);
448 $string = preg_replace("#\[msg=(.+?)\](.+?)\[/msg\]#is", "\\2 --> \\1", $string);
449 if (isset($bbcode_img) && $settings['bbcode_img'] == 1)
451 $string = preg_replace("#\[img\](.+?)\[/img\]#is", "\\1", $string);
452 $string = preg_replace("#\[img\|left\](.+?)\[/img\]#is", "\\1", $string);
453 $string = preg_replace("#\[img\|right\](.+?)\[/img\]#is", "\\1", $string);
455 return $string;
456 } # End: unbbcode
461 * replaces text smilies with smiley images
463 * @param string $string
464 * @return string $string
466 function smilies($string) {
467 global $connid, $db_settings;
469 $result = mysql_query("SELECT file, code_1, code_2, code_3, code_4, code_5, title FROM ".$db_settings['smilies_table'], $connid);
470 while($data = mysql_fetch_assoc($result))
472 $title = ($data['title']!='') ? ' title="'.htmlspecialchars($data['title']).'"' : '';
473 $string = ($data['code_1']!='') ? str_replace($data['code_1'], '<img src="img/smilies/'.$data['file'].'" alt="'.$data['code_1'].'"'.$title.' />', $string) : $string;
474 $string = ($data['code_2']!='') ? str_replace($data['code_2'], '<img src="img/smilies/'.$data['file'].'" alt="'.$data['code_2'].'"'.$title.' />', $string) : $string;
475 $string = ($data['code_3']!='') ? str_replace($data['code_3'], '<img src="img/smilies/'.$data['file'].'" alt="'.$data['code_3'].'"'.$title.' />', $string) : $string;
476 $string = ($data['code_4']!='') ? str_replace($data['code_4'], '<img src="img/smilies/'.$data['file'].'" alt="'.$data['code_4'].'"'.$title.' />', $string) : $string;
477 $string = ($data['code_5']!='') ? str_replace($data['code_5'], '<img src="img/smilies/'.$data['file'].'" alt="'.$data['code_5'].'"'.$title.' />', $string) : $string;
479 mysql_free_result($result);
481 return $string;
482 } # End: smilies
487 * puts the quote symbol to the begin of a line
489 * @param string $string
490 * @return string $string
492 function zitat($string) {
493 global $settings;
495 return str_replace('<p>'.$settings['quote_symbol'].' ', '<p class="citation">'.$settings['quote_symbol'].' ', $string);
497 } # End: zitat
502 * make code in blocks to codeblocks
504 * @param string $string
505 * @return string $string
507 function codeblock($string) {
508 global $settings;
511 if (preg_match("#<p><code>(.+?)</code></p>#is", $string))
513 return preg_replace("#<p><code>(.+?)</code></p>#ise", "'<pre><code>'.br2nl('\\1').'</code></pre>'", $string);
515 else
517 return $string;
520 return $string;
521 } # End: codeblock
527 * @param string
528 * @return string
530 function br2nl($data) {
531 return preg_replace( '!<br.*>!iU', "", $data );
537 * puts the quote symbol to the begin of a line for RSS-feeds
539 * @param string $string
540 * @return string $string
542 function rss_quote($string) {
543 global $settings;
545 $string = preg_replace("/^".htmlspecialchars($settings['quote_symbol'])."\\s+(.*)/", "<i>".htmlspecialchars($settings['quote_symbol'])." \\1</i>", $string);
546 $string = preg_replace("/\\n".htmlspecialchars($settings['quote_symbol'])."\\s+(.*)/", "<i>".htmlspecialchars($settings['quote_symbol'])." \\1</i>", $string);
547 $string = preg_replace("/\\n ".htmlspecialchars($settings['quote_symbol'])."\\s+(.*)/", "<i>".htmlspecialchars($settings['quote_symbol'])." \\1</i>", $string);
549 return $string;
550 } # End: rss_quote
555 * displays the error messages
557 * @param array $errors
558 * @return string $messages
560 function errorMessages($error) {
561 global $lang;
563 $r = "<h3>".$lang['error_headline']."</h3>\n";
564 $r .= "<ul>\n";
565 foreach ($error as $err)
567 $r .= " <li>".htmlspecialchars($err)."</li>\n";
569 $r .= "</ul>\n";
570 return $r;
571 } # End: errorMessages
576 * replaces the template placeholders with the computed contents
579 function parse_template() {
580 global $settings, $lang, $header, $cssLink, $additionalJS, $footer, $wo, $ao, $topnav, $subnav_1, $subnav_2, $footer_info_dump, $search, $show_postings, $counter;
582 $template = implode("",file($settings['template']));
584 if ($settings['home_linkaddress'] != "" && $settings['home_linkname'] != "") $template = preg_replace("#\{IF:HOME-LINK\}(.+?)\{ENDIF:HOME-LINK\}#is", "\\1", $template);
585 else $template = preg_replace("#\{IF:HOME-LINK\}(.+?)\{ENDIF:HOME-LINK\}#is", "", $template);
587 $template = str_replace("{LANGUAGE}",strip_tags($lang['language']),$template);
588 $template = str_replace("{CHARSET}",strip_tags($lang['charset']),$template);
589 $title = isset($wo) ? $settings['forum_name']." - ".htmlspecialchars($wo) : $settings['forum_name'];
590 $description = isset($wo) ? $settings['forum_name'].": ".htmlspecialchars($wo) : $settings['forum_name'];
591 $template = str_replace("{TITLE}",$title,$template);
592 $template = str_replace("{DESCRIPTION}",$description,$template);
593 $template = str_replace("{LOAD-CSS}",$cssLink,$template);
594 $template = str_replace('{ADD-JS}',$additionalJS,$template);
595 $template = str_replace('{SCRIPT-VERSION-STRING}',$settings['version'],$template);
596 $template = str_replace("{FORUM-NAME}",$settings['forum_name'],$template);
597 $template = str_replace('{HOME-ADDRESS}',$settings['home_linkaddress'],$template);
598 $template = str_replace('{HOME-LINK}',$settings['home_linkname'],$template);
599 $template = str_replace('{LOAD-TIME}',$lang['forum_load_message'],$template);
600 $template = str_replace('{FORUM-ADDRESS}',$settings['forum_address'],$template);
601 $template = str_replace('{CONTACT}',$lang['contact_linkname'],$template);
603 // User menu:
604 if (isset($_SESSION[$settings['session_prefix']."user_name"]))
606 if (isset($_SESSION[$settings['session_prefix'].'user_type']) && $_SESSION[$settings['session_prefix'].'user_type']=="admin")
608 $user_menu_admin = ' | <a href="admin.php" title="'.strip_tags($lang['admin_area_linktitle']).'">'.$lang['admin_area_linkname'].'</a>';
610 else
612 $user_menu_admin = "";
614 $user_menu = '<a href="user.php?id='.$_SESSION[$settings['session_prefix'].'user_id'].'" title="'.strip_tags($lang['own_userdata_linktitle']).'"><b>'.htmlspecialchars($_SESSION[$settings['session_prefix'].'user_name']).'</b></a> | <a href="login.php" title="'.strip_tags($lang['logout_linktitle']).'">'.$lang['logout_linkname'].'</a> | <a href="user.php" title="'.strip_tags($lang['user_area_linktitle']).'">'.$lang['user_area_linkname'].'</a>'.$user_menu_admin;
616 else
618 $user_menu = '<a href="login.php" rel="nofollow" title="'.strip_tags($lang['login_linktitle']).'">'.$lang['login_linkname'].'</a> | <a href="register.php" rel="nofollow" title="'.strip_tags($lang['register_linktitle']).'">'.$lang['register_linkname'].'</a>';
620 $user_menu .= ' | <a href="search.php" rel="nofollow" title="'.strip_tags($lang['search_formtitle']).'">'.$lang['search_linkname'].'</a>';
621 $template = str_replace("{USER-MENU}",$user_menu,$template);
623 // Search:
624 $search_dump = "\n".'<form action="search.php" method="get" title="'.strip_tags($lang['search_formtitle']).'"><div class="search">'."\n";
625 $search_dump .= '<label for="search">'.$lang['search_marking'].'&nbsp;</label>';
626 # if (isset($search)) $search_match = htmlspecialchars(stripslashes($search)); else $search_match = "";
627 $search_dump .= '<input class="searchfield" type="text" id="search" name="search" value="" size="20" />&nbsp;<input type="image" name="" src="img/submit.gif" alt="&raquo;" /></div></form>'."\n";
628 $template = str_replace("{SEARCH}",$search_dump,$template);
630 // Sub navigation:
631 $tnd = (isset($topnav)) ? $topnav : "";
632 $template = str_replace("{LOCATION}",$tnd,$template);
634 $subnav_1_dump = (isset($subnav_1)) ? $subnav_1 : "&nbsp;";
635 $template = str_replace("{SUB-NAVIGATION-1}",$subnav_1_dump,$template);
637 $subnav_2_dump = (isset($subnav_2)) ? $subnav_2 : "&nbsp;";
638 $template = str_replace("{SUB-NAVIGATION-2}",$subnav_2_dump,$template);
640 // Footer:
641 $template = str_replace("{COUNTER}",$counter,$template);
642 if ($settings['provide_rssfeed'] == 1 && $settings['access_for_users_only'] == 0)
644 $rss_feed_link = '<link rel="alternate" type="application/rss+xml" title="RSS Feed" href="rss.php" />';
645 $rss_feed_button = '<a href="rss.php"><img src="img/rss.png" width="14" height="14" alt="RSS Feed" /></a><br />';
647 else
649 $rss_feed_link = '';
650 $rss_feed_button = '';
652 $template = str_replace("{RSS-FEED-LINK}",$rss_feed_link,$template);
653 $template = str_replace("{RSS-FEED-BUTTON}",$rss_feed_button,$template);
655 $template_parts = explode("{CONTENT}",$template);
656 $header = (isset($template_parts[0])) ? $template_parts[0] : "";
657 $footer = (isset($template_parts[1])) ? $template_parts[1] : "";
658 } # End: parse_template