back");
$pages=1;
if(!isset($page) || $site='') $page=1;
if(!isset($type)) $type = "ASC";
$max=$maxposts;
for ($n=$max; $n<=$gesamt; $n+=$max) {
if($gesamt>$n) $pages++;
}
if($pages>1) $page_link = makepagelink("index.php?site=forum_topic&topic=$topic&type=$type", $page, $pages);
if($type=="ASC") {
$sorter='Sort: ';
} else {
$sorter='Sort: ';
}
if($page==1) $start=0;
if($page>1) $start=$page*$max-$max;
safe_query("UPDATE ".PREFIX."forum_topics SET views=views+1 WHERE topicID='$topic' ");
// viewed topics
$getviewedtopics=safe_query("SELECT topics FROM ".PREFIX."user WHERE userID='$userID'");
$gv=mysql_fetch_array($getviewedtopics);
if($gv[topics]=="") { //wenn noch keine topics besucht wurden
$array[]=$topic;
$array[]=time();
}
else {
$string=$gv[topics];
$array=explode(":", $string);
$anzarray=count($array);
for($i=0; $i<$anzarray; $i++) {
if($array[$i]==$topic) { // wenn topic bereits besucht wurde, timestamp updaten
$array[$i+1]=time();
$found=true;
}
}
if(!$found) { // wenn topic noch nicht besucht wurde, neu eintragen
$array[]=$topic;
$array[]=time();
}
}
$string_new=implode(":", $array);
safe_query("UPDATE ".PREFIX."user SET topics='$string_new' WHERE userID='$userID'");
// end viewed topics
$topicname=getinput($dt[topic]);
$ergebnis = safe_query("SELECT * FROM ".PREFIX."forum_boards WHERE boardID='$dt[boardID]' ");
$db = mysql_fetch_array($ergebnis);
$boardname = $db[name];
$moderators=getmoderators($dt[boardID]);
if($db[intern]) {
if(! isinternboarduser($userID)) die('You have no permission to view intern boards!
');
}
$topicactions=' ';
if($loggedin) $topicactions.=' ';
if($dt[closed]) $closed='';
else {
$closed='';
$topicactions.='';
}
$posttype='topic';
eval ("\$forum_topics_title = \"".gettemplate("forum_topics_title")."\";");
echo $forum_topics_title;
eval ("\$forum_topics_actions = \"".gettemplate("forum_topics_actions")."\";");
echo $forum_topics_actions;
if($dt[closed]) {
echo'
';
}
if($edit && !$dt[closed]) {
$id = $_GET['id'];
$dr = mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."forum_posts WHERE postID='".$id."'"));
$topic = $_GET['topic'];
$bg1=BG_1;
$_sticky = ($dt[sticky] == '1') ? 'checked="checked"' : '';
$anz = mysql_num_rows(safe_query("SELECT * FROM ".PREFIX."forum_posts WHERE topicID='".$dt[topicID]."' AND postID='".$id."' AND poster='".$userID."' ORDER BY date ASC LIMIT 0,1"));
if($anz OR isforumadmin($userID) OR ismoderator($userID,$dt[boardID])) {
if(istopicpost($dt[topicID], $id)) {
$bg1=BG_1;
// topicmessage
$message = getinput($dr['message']);
$post = $id;
$board = $dt['boardID'];
// notification check
$notifyqry = safe_query("SELECT * FROM ".PREFIX."forum_notify WHERE topicID='".$topic."' AND userID='".$userID."'");
if(mysql_num_rows($notifyqry)) {
$notify = ' Notify me when a reply is posted
';
} else {
$notify = ' Notify me when a reply is posted
';
}
//STICKY
if(isforumadmin($userID) || ismoderator($userID, $board)) {
$chk_sticky = '
'."\n".' Make this topic sticky';
}
else {
$chk_sticky = '';
}
// topic icon list
$iconlist = '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
';
$iconlist = str_replace('value="'.$dt[icon].'"', 'value="'.$dt[icon].'" checked', $iconlist);
eval ("\$addbbcode = \"".gettemplate("addbbcode")."\";");
eval ("\$forum_edittopic = \"".gettemplate("forum_edittopic")."\";");
echo $forum_edittopic;
} else {
//STICKY
if(isforumadmin($userID) || ismoderator($userID, $board)) {
$chk_sticky = '
'."\n".' Make this topic sticky';
}
else {
$chk_sticky = '';
}
$dr['message']=getinput($dr['message']);
eval ("\$addbbcode = \"".gettemplate("addbbcode")."\";");
eval ("\$forum_editpost = \"".gettemplate("forum_editpost")."\";");
echo $forum_editpost;
}
} else {
echo 'Permission denied.
';
}
$replys = safe_query("SELECT * FROM ".PREFIX."forum_posts WHERE topicID='$topic' ORDER BY date DESC LIMIT $start, $max");
}
elseif($addreply && !$dt[closed]) {
if($loggedin) {
if($_POST['preview']) {
$bg1=BG_1;
$bg2=BG_2;
$time=date("H:i", time());
$date="today";
$message_preview = $_POST['message'];
$message = cleartext($_POST['message']);
$message = toggle($message, 'xx');
$username=''.getnickname($userID).'';
if(isclanmember($userID)) $member=' ';
else $member='';
if(getavatar($userID)) $avatar='';
else $avatar='';
if(getsignatur($userID)) $signatur='
'.cleartext(getsignatur($userID));
else $signatur='';
if (getemail($userID)) $email = '';
else $email='';
$pm='';
$buddy='';
$statuspic='';
$sem = '^[http://]+[a-z0-9_\.-]+[a-z0-9_-]+$';
if(!(eregi($sem, gethomepage($userID)))) $hp='';
else $hp='';
$registered = getregistered($userID);
$posts = getuserforumposts($userID);
$_sticky = ($dt[sticky] == '1' || $_POST['sticky'] == '1') ? 'checked="checked"' : '';
if(isforumadmin($userID) || isanymoderator($userID)) {
if(isanymoderator($userID)) {
$usertype="Moderator";
$rang='';
$chk_sticky = '
'."\n".' Make this topic sticky';
}
if(isforumadmin($userID)) {
$usertype="Administrator";
$rang='';
$chk_sticky = '
'."\n".' Make this topic sticky';
}
}
else {
$ergebnis=safe_query("SELECT * FROM ".PREFIX."forum_ranks WHERE $posts >= postmin AND $posts <= postmax");
$ds=mysql_fetch_array($ergebnis);
$usertype=$ds[rank];
$rang='';
$chk_sticky = '';
}
$action='';
echo'
Preview |
|
';
eval ("\$forum_topic_content = \"".gettemplate("forum_topic_content")."\";");
echo $forum_topic_content;
echo'
';
$message = $message_preview;
}
else {
if($quoteID) {
$ergebnis=safe_query("SELECT poster,message FROM ".PREFIX."forum_posts WHERE postID='$quoteID'");
$ds=mysql_fetch_array($ergebnis);
$message='[quote]'.getnickname($ds[poster]).' wrote:[hr]'.$ds[message].'[/quote]';
}
}
$_sticky = ($dt[sticky] == '1' || $_POST['sticky'] == '1') ? 'checked="checked"' : '';
if(isforumadmin($userID) || ismoderator($userID, $dt[boardID])) {
$chk_sticky = '
'."\n".' Make this topic sticky';
}
else {
$chk_sticky = '';
}
$bg1=BG_1;
$board = $dt[boardID];
eval ("\$addbbcode = \"".gettemplate("addbbcode")."\";");
eval ("\$forum_newreply = \"".gettemplate("forum_newreply")."\";");
echo $forum_newreply;
}
else {
echo'
To start a topic you have to be registered and logged in!
• register now';
}
$replys = safe_query("SELECT * FROM ".PREFIX."forum_posts WHERE topicID='$topic' ORDER BY date DESC LIMIT 0, $max");
}
else $replys = safe_query("SELECT * FROM ".PREFIX."forum_posts WHERE topicID='$topic' ORDER BY date $type LIMIT $start, $max");
eval ("\$forum_topic_head = \"".gettemplate("forum_topic_head")."\";");
echo $forum_topic_head;
$i=1;
while($dr=mysql_fetch_array($replys)) {
if($i%2) {
$bg1=BG_1;
$bg2=BG_2;
}
else {
$bg1=BG_3;
$bg2=BG_4;
}
$date=date("d.m.Y", $dr[date]);
$time=date("H:i", $dr[date]);
$today=date("d.m.Y", time());
$yesterday = date("d.m.Y", time()-3600*24);
if($date==$today) $date="today";
elseif($date==$yesterday && $date<$today) $date="yesterday";
else $date=$date;
$message = cleartext($dr[message]);
$message = toggle($message, $dr[postID]);
$postID= $dr[postID];
$username=''.getnickname($dr[poster]).'';
if(isclanmember($dr[poster])) $member=' ';
else $member='';
if(getavatar($dr[poster])) $avatar='';
else $avatar='';
if(getsignatur($dr[poster])) $signatur='
'.cleartext(getsignatur($dr[poster]));
else $signatur='';
if (getemail($dr[poster])) $email = '';
else $email='';
$pm='';
$buddy='';
if($loggedin && $dr[poster]!=$userID) {
$pm='';
if(isignored($userID, $dr[poster])) $buddy='';
elseif(isbuddy($userID, $dr[poster])) $buddy='';
else $buddy='';
}
if(isonline($dr[poster])=="offline") $statuspic='';
else $statuspic='';
$sem = '^[http://]+[a-z0-9_\.-]+[a-z0-9_-]+$';
if(!(eregi($sem, gethomepage($dr[poster])))) $hp='';
else $hp='';
if(!$dt[closed]) $quote='';
$registered = getregistered($dr[poster]);
$posts = getuserforumposts($dr[poster]);
if(isforumadmin($dr[poster]) || isanymoderator($dr[poster])) {
if(isanymoderator($userID)) {
$usertype="Moderator";
$rang='';
}
if(isforumadmin($dr[poster])) {
$usertype="Administrator";
$rang='';
}
}
else {
$ergebnis=safe_query("SELECT * FROM ".PREFIX."forum_ranks WHERE $posts >= postmin AND $posts <= postmax");
$ds=mysql_fetch_array($ergebnis);
$usertype=$ds[rank];
$rang='';
}
$action='';
if(($userID == $dr[poster] OR isforumadmin($userID) OR ismoderator($userID,$dt[boardID]))&& !$dt[closed]) $actions=' ';
if(isforumadmin($userID) OR ismoderator($userID,$dt[boardID])) $actions.='';
eval ("\$forum_topic_content = \"".gettemplate("forum_topic_content")."\";");
echo $forum_topic_content;
unset($actions);
$i++;
}
if(isforumadmin($userID) OR ismoderator($userID,getboardid($topic)))
$adminactions=' select all
';
eval ("\$forum_topic_foot = \"".gettemplate("forum_topic_foot")."\";");
echo $forum_topic_foot;
eval ("\$forum_topics_actions = \"".gettemplate("forum_topics_actions")."\";");
echo $forum_topics_actions;
echo''.$adminactions.'
';
if($dt[closed]) {
echo'';
}
else {
if(!$loggedin && !$edit) {
echo'To reply to this topic you have to be registered and logged in!
• register now
• log in';
}
}
}
function announcement($announcement, $delete, $edit) {
global $userID;
global $loggedin;
global $picsize_l;
$pagebg=PAGEBG;
$border=BORDER;
$bghead=BGHEAD;
$bgcat=BGCAT;
if($edit) {
$ergebnis = safe_query("SELECT * FROM ".PREFIX."forum_announcements WHERE announceID='$announcement' ");
$ds = mysql_fetch_array($ergebnis);
eval ("\$addbbcode = \"".gettemplate("addbbcode")."\";");
eval ("\$forum_announcement_edit = \"".gettemplate("forum_announcement_edit")."\";");
echo $forum_announcement_edit;
}
else {
$ergebnis = safe_query("SELECT * FROM ".PREFIX."forum_announcements WHERE announceID='$announcement' ");
$ds = mysql_fetch_array($ergebnis);
$topicname=cleartext($ds[topic]);
$ergebnis = safe_query("SELECT * FROM ".PREFIX."forum_boards WHERE boardID='$ds[boardID]' ");
$db = mysql_fetch_array($ergebnis);
$dt[boardID]=$ds[boardID];
$boardname = $db[name];
$topic=$announcement;
$posttype='announcement';
$moderators=getmoderators($ds[boardID]);
if($db[intern]) {
if(! isinternboarduser($userID)) die('You have no permission to view intern boards!
');
}
eval ("\$forum_topics_title = \"".gettemplate("forum_topics_title")."\";");
echo $forum_topics_title;
eval ("\$forum_topic_head = \"".gettemplate("forum_topic_head")."\";");
echo $forum_topic_head;
echo '
';
$date=date("d.m.Y", $ds[date]);
$time=date("H:i", $ds[date]);
$today=date("d.m.Y", time());
$yesterday = date("d.m.Y", time()-3600*24);
if($date==$today) $date="today";
elseif($date==$yesterday && $date<$today) $date="yesterday";
else $date=$date;
$message=cleartext($ds[announcement]);
$message = toggle($message, $ds[announceID]);
$username=getnickname($ds[userID]);
$member=' ';
if(getavatar($ds[userID])) $avatar='';
else $avatar='';
if(getsignatur($ds[userID])) $signatur='
'.cleartext(getsignatur($ds[userID]));
else $signatur='';
if (getemail($ds[userID])) $email = '';
else $email='';
if($loggedin && $ds[userID] != $userID) {
$pm='';
if(isignored($userID, $ds[userID])) $buddy='';
elseif(isbuddy($userID, $ds[userID])) $buddy='';
else $buddy='';
}
if(isonline($ds[userID])=="offline") $statuspic='';
else $statuspic='';
$sem = '^[http://]+[a-z0-9_\.-]+[a-z0-9_-]+$';
if(!(eregi($sem, gethomepage($ds[userID])))) $hp='';
else $hp='';
$registered = getregistered($ds[userID]);
$posts = getuserforumposts($ds[userID]);
if(isforumadmin($ds[userID]) || isanymoderator($userID)) {
if(isanymoderator($userID)) {
$usertype="Moderator";
$rang='';
}
if(isforumadmin($ds[userID])) {
$usertype="Administrator";
$rang='';
}
}
else {
$result=safe_query("SELECT * FROM ".PREFIX."forum_ranks WHERE $posts >= postmin AND $posts <= postmax");
$dr=mysql_fetch_array($result);
$usertype=$dr[rank];
$rang='';
}
if(isforumadmin($userID)) $actions='
';
else $actions='';
$bg1=BG_1;
$bg2=BG_2;
eval ("\$forum_topic_content = \"".gettemplate("forum_topic_content")."\";");
echo $forum_topic_content;
eval ("\$forum_topic_foot = \"".gettemplate("forum_topic_foot")."\";");
echo $forum_topic_foot;
}
}
if($announcement) announcement($announcement, $delete, $edit);
else showtopic($topic, $edit, $id, $addreply, $quoteID, $type);
?>