Jump to content

Need help fixing duplication of PHP data in page source.


Doc20

Recommended Posts

Hey all,

 

I help a friend with his Webspell CMS site (not a big fan of it, I should add).  Anyways, he wanted me to add the ability to display a second image on a user's topics/posts.  I have successfully added this feature.  However, there is a snag that has been boggling my mind for about a week now.

 

Essentially, if a user has a special rank (I have called this 'position' throughout the coding), and a user below them posts that does not have a defined position, it gives them the position of the person above them.

 

Here is a screenshot to demonstrate this:

 

rankd1.png

 

In this image, the user "CaptBrent" has the rank 'general of the army' and a position of 'sos'.  The user below him has no rank (although a 'no rank' image has been defined just as a place holder in this image; the rank id for no rank is 45).  However, this user is inheriting the position of the CaptBrent.

 

It is supposed to just not display any additional code on users that have a id of 0 (as they do not have a defined position/rank).

 

 

 

The rank ID for sos is 82.

 

In this following screenshot, you will see CaptBrent has this rank ID 82, the other user does not (has a 0 by default); yet they are getting the rank id of 82 from the code, therefore it displays that rank. 

 

rankd2.png]

 

I have attached the full code for the 3 files that I believe are involved, as a well as the page source so you can see what the page is giving out.

 

forum_topic.php  (lines of interest:  455-483 & 622-650)

<?php


if(isset($_GET['page'])) $page = (int)$_GET['page'];
if(isset($_GET['delete'])) $delete = (bool)$_GET['delete'];					else $delete='';
if(isset($_GET['edit'])) $edit = (bool)$_GET['edit'];						else $edit='';
if(isset($_REQUEST['topic'])) $topic = (int)$_REQUEST['topic'];				else $topic='';
if(isset($_REQUEST['addreply'])) $addreply = (bool)$_REQUEST['addreply'];	else $addreply='';
if(isset($_GET['type'])) $type = $_GET['type'];								else $type='';
if(isset($_GET['quoteID'])) $quoteID = (int)$_GET['quoteID'];				else $quoteID='';
$do_sticky = (isset($_POST['sticky'])) ? true : false;

if(isset($_POST['newreply']) && !(bool)$_POST['preview']) {
include("_mysql.php");
include("_settings.php");
include("_functions.php");
$_language->read_module('forum');

if(!$userID) die($_language->module['not_logged']);

$message = $_POST['message'];
$topic = (int)$_POST['topic'];
$page = (int)$_POST['page'];

if(!(mb_strlen(trim($message)))) die($_language->module['forgot_message']);
$ds=mysql_fetch_array(safe_query("SELECT closed, writegrps, boardID FROM ".PREFIX."forum_topics WHERE topicID='".$topic."'"));
if($ds['closed']) die($_language->module['topic_closed']);

$writer = 0;
if($ds['writegrps'] != "") {
	$writegrps = explode(";", $ds['writegrps']);
	foreach($writegrps as $value) {
		if(isinusergrp($value, $userID)) {
			$writer = 1;
			break;
		}
	}
	if(ismoderator($userID, $ds['boardID'])) $writer = 1;
}
else $writer = 1;
if(!$writer) die($_language->module['no_access_write']);
$do_sticky = (isset($_POST['sticky'])) ? true : false;
if($do_sticky AND (isforumadmin($userID) OR isanymoderator($userID, $ds['boardID']))) $do_sticky=true;
else $do_sticky=false;

$date=time();
safe_query("INSERT INTO ".PREFIX."forum_posts ( boardID, topicID, date, poster, message ) VALUES( '".$_REQUEST['board']."', '$topic', '$date', '$userID', '".$message."' ) ");
$lastpostID = mysql_insert_id();
safe_query("UPDATE ".PREFIX."forum_boards SET posts=posts+1 WHERE boardID='".$_REQUEST['board']."' ");
safe_query("UPDATE ".PREFIX."forum_topics SET lastdate='".$date."', lastposter='".$userID."', lastpostID='".$lastpostID."', replys=replys+1, sticky='$do_sticky' WHERE topicID='$topic' ");

// check if there are more than 1000 unread topics => delete oldest one
$dv = safe_query("SELECT topics FROM ".PREFIX."user WHERE userID='".$userID."'");
$array = explode('|', $dv['topics']);
if(count($array)>=1000) safe_query("UPDATE ".PREFIX."user SET topics='|".implode('|', array_slice($array, 2))."' WHERE userID='".$userID."'");
unset($array);

// add this topic to unread
safe_query("UPDATE ".PREFIX."user SET topics=CONCAT(topics, '".$topic."|') WHERE topics NOT LIKE '%|".$topic."|%'"); // update unread topics, format: |oldstring| => |oldstring|topicID|

$emails=array();
$ergebnis=safe_query("SELECT f.userID, u.email, u.language FROM ".PREFIX."forum_notify f JOIN ".PREFIX."user u ON u.userID=f.userID WHERE f.topicID=$topic");
while($ds=mysql_fetch_array($ergebnis)) {
	$emails[] = Array('mail'=>$ds['email'], 'lang'=>$ds['language']);
}
safe_query("DELETE FROM ".PREFIX."forum_notify WHERE topicID='$topic'");

if(count($emails)) {

	$de=mysql_fetch_array(safe_query("SELECT nickname FROM ".PREFIX."user WHERE userID='$userID'"));
	$poster=$de['nickname'];
	$de=mysql_fetch_array(safe_query("SELECT topic FROM ".PREFIX."forum_topics WHERE topicID='$topic'"));
	$topicname=getinput($de['topic']);

	$link="http://".$hp_url."/index.php?site=forum_topic&topic=".$topic;
	$maillanguage = new Language;
	$maillanguage->set_language($default_language);

	foreach($emails as $email) {
		$maillanguage->set_language($email['lang']);
		$maillanguage->read_module('forum');
		$forum_topic_notify = str_replace(Array('%poster%', '%topic_link%', '%pagetitle%', '%hpurl%'), Array(html_entity_decode($poster), $link, $hp_title, 'http://'.$hp_url), $maillanguage->module['notify_mail']);
		$header = "From:".$admin_email."\nContent-type: text/plain; charset=utf-8\n";
		@mail($email['mail'], $maillanguage->module['new_reply'].' ('.$hp_title.')', $forum_topic_notify, $header);
	}
}

if(isset($_POST['notify']) and (bool)$_POST['notify']) {
	safe_query("INSERT INTO ".PREFIX."forum_notify (topicID, userID) values('".$topic."', '".$userID."') ");
}
header("Location: index.php?site=forum_topic&topic=".$topic."&page=".$page);
exit();
}
elseif(isset($_POST['editreply']) and (bool)$_POST['editreply']) {
include("_mysql.php");
include("_settings.php");
include("_functions.php");
$_language->read_module('forum');

if(!isforumposter($userID,$_POST['id']) and !isforumadmin($userID) and !ismoderator($userID,$_GET['board'])) die($_language->module['no_accses']);

$message = $_POST['message'];
$id = (int)$_POST['id'];
$check=mysql_num_rows(safe_query("SELECT postID FROM ".PREFIX."forum_posts WHERE postID='".$id."' AND poster='".$userID."'"));
if(($check or isforumadmin($userID) or ismoderator($userID,(int)$_GET['board'])) and mb_strlen(trim($message))) {
	$do_sticky = (isset($_POST['sticky'])) ? true : false;
	if($do_sticky AND (isforumadmin($userID) OR isanymoderator($userID, (int)$_GET['board']))) $do_sticky=true;
	else $do_sticky=false;

	$date=date("d.m.Y - H:i", time());
	safe_query("UPDATE ".PREFIX."forum_posts SET message = '".$message."' WHERE postID='$id' ");
	safe_query("UPDATE ".PREFIX."forum_topics SET sticky='$do_sticky' WHERE topicID='".(int)$_GET['topic']."'");
	safe_query("DELETE FROM ".PREFIX."forum_notify WHERE userID='$userID' AND topicID='".(int)$_GET['topic']."'");
	if(isset($_POST['notify'])) if((bool)$_POST['notify']) safe_query("INSERT INTO ".PREFIX."forum_notify (`notifyID`, `topicID`, `userID`) VALUES ('', '$userID', '".(int)$_GET['topic']."')");
}
header("Location: index.php?site=forum_topic&topic=".(int)$_GET['topic']."&page=".(int)$_GET['page']);
}
elseif(isset($_POST['saveedittopic']) and (bool)$_POST['saveedittopic']) {
include("_mysql.php");
include("_settings.php");
include("_functions.php");
$_language->read_module('forum');

if(!isforumadmin($userID) and !isforumposter($userID,$_POST['post']) and !ismoderator($userID,$_GET['board'])) die($_language->module['no_accses']);

$board = (int)$_GET['board'];
$topic = (int)$_GET['topic'];
$post = $_POST['post'];
if(isset($_POST['notify']))$notify = (bool)$_POST['notify'];
else $notify = false;
$topicname = $_POST['topicname'];
$message = $_POST['message'];
if(isset($_POST['icon'])) $icon = $_POST['icon'];
else $icon = '';
$do_sticky = (isset($_POST['sticky'])) ? true : false;
if($do_sticky AND (isforumadmin($userID) OR isanymoderator($userID, $board))) $do_sticky=true;
else $do_sticky=false;

safe_query("UPDATE ".PREFIX."forum_posts SET message='".$message."' WHERE postID='".$post."'");
safe_query("UPDATE ".PREFIX."forum_topics SET topic='".$topicname."', icon='".$icon."', sticky='".$do_sticky."' WHERE topicID='".$topic."'");

if($notify==1) {
	$notified = safe_query("SELECT * FROM ".PREFIX."forum_notify WHERE topicID='".$topic."' AND userID='".$userID."'");
	if(mysql_num_rows($notified)!=1) {
		safe_query("INSERT INTO ".PREFIX."forum_notify (notifyID, topicID, userID) VALUES ('', '$topic', '$userID')");
	}
} else {
	safe_query("DELETE FROM ".PREFIX."forum_notify WHERE topicID='".$topic."' AND userID='".$userID."'");
}
header("Location: index.php?site=forum_topic&topic=".$topic);
}

function showtopic($topic, $edit, $addreply, $quoteID, $type) {
global $userID;
global $loggedin;
global $page;
global $maxposts;
global $preview;
global $message;
global $picsize_l;
global $_language;

$_language->read_module('forum');
$_language->read_module('bbcode', true);

$pagebg=PAGEBG;
$border=BORDER;
$bghead=BGHEAD;
$bgcat=BGCAT;

$thread = safe_query("SELECT * FROM ".PREFIX."forum_topics WHERE topicID='$topic' ");
$dt = mysql_fetch_array($thread);

$usergrp = 0;
$writer = 0;
$ismod = ismoderator($userID, $dt['boardID']);
if($dt['writegrps'] != "" and !$ismod) {
	$writegrps = explode(";", $dt['writegrps']);
	foreach($writegrps as $value) {
		if(isinusergrp($value, $userID)) {
			$usergrp = 1;
			$writer = 1;
			break;
		}
	}
}
else $writer = 1;
if($dt['readgrps'] != "" and !$usergrp and !$ismod) {
	$readgrps = explode(";", $dt['readgrps']);
	foreach($readgrps as $value) {
		if(isinusergrp($value, $userID)) {
			$usergrp = 1;
			break;
		}
	}
	if(!$usergrp){ 
		echo $_language->module['no_permission'];
    	redirect('index.php?site=forum',$_language->module['no_permission'],2);
    	return;
	}
}
$gesamt = mysql_num_rows(safe_query("SELECT topicID FROM ".PREFIX."forum_posts WHERE topicID='$topic'"));
if($gesamt==0) die($_language->module['topic_not_found']." <a href=\"javascript:history.back()\">back</a>");
$pages=1;
if(!isset($page) || $site='') $page=1;
if(isset($type)){
  if(!(($type=='ASC') || ($type=='DESC'))) $type="ASC";
}
else{
  $type="ASC";
}
$max=$maxposts;
$pages=ceil($gesamt/$maxposts);

$page_link = '';
if($pages>1) $page_link = makepagelink("index.php?site=forum_topic&topic=$topic&type=$type", $page, $pages);
if($type=="ASC") {
	$sorter='<a href="index.php?site=forum_topic&topic='.$topic.'&page='.$page.'&type=DESC">'.$_language->module['sort'].':</a> <img src="images/icons/asc.gif" alt="" />';
}
else {
	$sorter='<a href="index.php?site=forum_topic&topic='.$topic.'&page='.$page.'&type=ASC">'.$_language->module['sort'].':</a> <img src="images/icons/desc.gif" alt="" />';
}

$start=0;
if($page>1) $start=$page*$max-$max;

safe_query("UPDATE ".PREFIX."forum_topics SET views=views+1 WHERE topicID='$topic' ");

// viewed topics

if(mysql_num_rows(safe_query("SELECT userID FROM ".PREFIX."user WHERE topics LIKE '%|".$topic."|%'"))) {

	$gv=mysql_fetch_array(safe_query("SELECT topics FROM ".PREFIX."user WHERE userID='$userID'"));
	$array=explode("|", $gv['topics']);
	$new='|';

	foreach($array as $split) {
		if($split != "" AND $split!=$topic) $new = $new.$split.'|';
	}

	safe_query("UPDATE ".PREFIX."user SET topics='".$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']);

$topicactions='<a href="printview.php?board='.$dt['boardID'].'&topic='.$topic.'" target="_blank"><img src="images/icons/printview.gif" border="0" alt="printview" /></a> ';
if($loggedin and $writer) $topicactions.='<a href="index.php?site=forum&addtopic=true&action=newtopic&board='.$dt['boardID'].'">'.$_language->module['newtopic_image'].'</a> <a href="index.php?site=forum_topic&topic='.$topic.'&addreply=true&page='.$pages.'&type='.$type.'">'.$_language->module['newreply_image'].'</a>';
if($dt['closed']) $closed=$_language->module['closed_image'];
else $closed='';
$posttype='topic';

$kathname = getcategoryname($db['category']);
  	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'<br /><br />'.$_language->module['closed_image'].'<br /><br />';
}

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 = '<input class="input" type="checkbox" name="notify" value="1" checked="checked" /> '.$_language->module['notify_reply'].'<br />';
			} else {
				$notify = '<input class="input" type="checkbox" name="notify" value="1" /> '.$_language->module['notify_reply'].'<br />';
			}
			//STICKY
			if(isforumadmin($userID) || ismoderator($userID, $board)) {
				$chk_sticky = '<br />'."\n".' <input class="input" type="checkbox" name="sticky" value="1" '.$_sticky.' /> '.$_language->module['make_sticky'];
			}
			else {
				$chk_sticky = '';
			}

			// topic icon list
			$iconlist = '<tr bgcolor="'.$bg1.'">
          <td><input type="radio" class="input" name="icon" value="ausrufezeichen.gif" />
          <img src="images/icons/topicicons/ausrufezeichen.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="biggrin.gif" />
          <img src="images/icons/topicicons/biggrin.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="boese.gif" />
          <img src="images/icons/topicicons/boese.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="bored.gif" />
          <img src="images/icons/topicicons/bored.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="cool.gif" />
          <img src="images/icons/topicicons/cool.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="eek.gif" />
          <img src="images/icons/topicicons/eek.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="frage.gif" />
          <img src="images/icons/topicicons/frage.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="frown.gif" />
          <img src="images/icons/topicicons/frown.gif" width="15" height="15" alt="" /></td>
        </tr>
        <tr bgcolor="'.$bg1.'">
          <td><input type="radio" class="input" name="icon" value="lampe.gif" />
          <img src="images/icons/topicicons/lampe.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="mad.gif" />
          <img src="images/icons/topicicons/mad.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="pfeil.gif" />
          <img src="images/icons/topicicons/pfeil.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="smile.gif" />
          <img src="images/icons/topicicons/smile.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="text.gif" />
          <img src="images/icons/topicicons/text.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="thumb_down.gif" />
          <img src="images/icons/topicicons/thumb_down.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="thumb_up.gif" />
          <img src="images/icons/topicicons/thumb_up.gif" width="15" height="15" alt="" /></td>
          <td><input type="radio" class="input" name="icon" value="wink.gif" />
          <img src="images/icons/topicicons/wink.gif" width="15" height="15" alt="" /></td>
        </tr>
        <tr bgcolor="'.$bg1.'">
            <td colspan="4"><input type="radio" class="input" name="icon" value="0" /> '.$_language->module['no_icon'].'</td>
          </tr>';
			if($dt['icon'])	$iconlist = str_replace('value="'.$dt['icon'].'"', 'value="'.$dt['icon'].'" checked="checked"', $iconlist);
			else $iconlist = str_replace('value="0"', 'value="0" checked="checked"', $iconlist);
			eval ("\$addbbcode = \"".gettemplate("addbbcode")."\";");
			eval ("\$forum_edittopic = \"".gettemplate("forum_edittopic")."\";");
			echo $forum_edittopic;
		}
		else {
			// notification check
			$notifyqry = safe_query("SELECT * FROM ".PREFIX."forum_notify WHERE topicID='".$topic."' AND userID='".$userID."'");
			if(mysql_num_rows($notifyqry)) {
				$notify = '<input class="input" type="checkbox" name="notify" value="1" checked="checked" /> '.$_language->module['notify_reply'];
			} else {
				$notify = '<input class="input" type="checkbox" name="notify" value="1" /> '.$_language->module['notify_reply'];
			}
        //STICKY
			if(isforumadmin($userID) || ismoderator($userID, $board)) {
				$chk_sticky = '<br />'."\n".' <input class="input" type="checkbox" name="sticky" value="1" '.$_sticky.' /> '.$_language->module['make_sticky'];
			}
			else {
				$chk_sticky = '';
			}
			$dr['message']=getinput($dr['message']);
			eval ("\$addbbcode = \"".gettemplate("addbbcode")."\";");
			eval ("\$forum_editpost = \"".gettemplate("forum_editpost")."\";");
			echo $forum_editpost;
		}
	}
	else {
		echo $_language->module['permission_denied'].'<br /><br />';
	}

	$replys = safe_query("SELECT * FROM ".PREFIX."forum_posts WHERE topicID='$topic' ORDER BY date DESC LIMIT $start, $max");
}
elseif($addreply && !$dt['closed']) {
	if($loggedin and $writer) {
		if(isset($_POST['preview'])) {
			$bg1=BG_1;
			$bg2=BG_2;

			$time=date("H:i", time());
			$date=$_language->module['today'];

			$message_preview = getforminput($_POST['message']);
			$postID = 0;

			$message = cleartext(getforminput($_POST['message']));

			$message = toggle($message, 'xx');
			$username='<a href="index.php?site=profile&id='.$userID.'"><b>'.getnickname($userID).'</b></a>';

			if(isclanmember($userID)) $member=' <img src="images/icons/member.gif" alt="'.$_language->module['clanmember'].'" />';
			else $member='';
			if($getavatar = getavatar($userID)) $avatar='<img src="images/avatars/'.$getavatar.'" alt="" />';
			else $avatar='';
			if($getsignatur = getsignatur($userID)) $signatur=cleartext($getsignatur);
			else $signatur='';
			if($getemail = getemail($userID) and !getemailhide($userID)) $email = '<a href="mailto:'.mail_protect($getemail).'"><img src="images/icons/email.gif" border="0" alt="email" /></a>';
			else $email='';
			if(isset($_POST['notify'])) $notify = 'checked="checked"';
			else $notify = '';
			$pm='';
			$buddy='';
			$statuspic='<img src="images/icons/online.gif" alt="online" />';
			$sem = '^[http://]+[a-z0-9_\.-]+[a-z0-9_-]+$';
			if(!(eregi($sem, gethomepage($userID)))) $hp='';
			else $hp='<a href="'.gethomepage($userID).'" target="_blank"><img src="images/icons/hp.gif" border="0" alt="'.$_language->module['homepage'].'" /></a>';
			$registered = getregistered($userID);
			$posts = getuserforumposts($userID);
			if(isset($_POST['sticky'])) $post_sticky = $_POST['sticky'];
			else $post_sticky = null;
			$_sticky = ($dt['sticky'] == '1' || $post_sticky == '1') ? 'checked="checked"' : '';

			if(isforumadmin($userID)) {
				$usertype=$_language->module['admin'];
				$rang='<img src="images/icons/ranks/admin.gif" alt="" />';
			}
			elseif(isanymoderator($userID)) {
				$usertype=$_language->module['moderator'];
				$rang='<img src="images/icons/ranks/moderator.gif" alt="" />';
			} else {
				$ergebnis=safe_query("SELECT * FROM ".PREFIX."forum_ranks WHERE $posts >= postmin AND $posts <= postmax AND special='0'");
				$ds=mysql_fetch_array($ergebnis);
				$usertype=$ds['rank'];
				$rang='<img src="images/icons/ranks/'.$ds['pic'].'" alt="" />';


			}
			$specialrang = "";
			$specialtype = "";
			$specialpos = "";
			$specialtypepos = "";
			$getrank = safe_query("SELECT IF(u.special_rank = 0, 0, CONCAT_WS(\"__\",r.rank, r.pic)) as RANK FROM ".PREFIX."user u LEFT JOIN ".PREFIX."forum_ranks r ON u.special_rank = r.rankID WHERE userID='".$userID."'");
			$getposition =   safe_query("SELECT IF(u.rank_position = 0, 0, CONCAT_WS(\"__\",r.rank, r.pic)) as POSITION FROM ".PREFIX."user u LEFT JOIN ".PREFIX."forum_ranks r ON u.rank_position = r.rankID WHERE userID='".$userID."'");
			$rank_data = mysql_fetch_assoc($getrank);
			$position_data =mysql_fetch_assoc($getposition);

		if($rank_data['RANK'] != '0'){
		$tmp_rank = explode("__",$rank_data['RANK']);
		$specialrang = $tmp_rank[0];
                        $specialtype = '<img src="images/icons/ranks/'
                        .$tmp_rank[1].
                              '" alt = "'
                        .$specialrang.
                        '" />';

	}
		if($position_data['POSITION'] != '0'){
		$tmp_position = explode("__",$position_data['POSITION']);
		$specialpos = $tmp_position[0];
                        $specialtypepos = '<img src="images/icons/ranks/'
                        .$tmp_position[1].
                            '" alt = "'
                        .$specialpos.
                          '" />';

	}



			if(isforumadmin($userID)) $chk_sticky = '<br />'."\n".' <input class="input" type="checkbox" name="sticky" value="1" '.$_sticky.' /> '.$_language->module['make_sticky'];
			elseif(isanymoderator($userID)) $chk_sticky = '<br />'."\n".' <input class="input" type="checkbox" name="sticky" value="1" '.$_sticky.' /> '.$_language->module['make_sticky'];
			else $chk_sticky = '';
			$quote = "";
			$actions = "";
			echo'<table width="100%" cellspacing="1" cellpadding="2" bgcolor="'.BORDER.'">
          <tr bgcolor="'.BGHEAD.'">
            <td colspan="2" class="title" align="center">'.$_language->module['preview'].'</td>
          </tr>
          <tr bgcolor="'.PAGEBG.'"><td colspan="2"></td></tr>';
          
			eval ("\$forum_topic_content = \"".gettemplate("forum_topic_content")."\";");
			echo $forum_topic_content;
        
			echo'</table>';

			$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']).']'.getinput($ds['message']).'[/quote]';
			}
		}
		if(isset($_POST['sticky'])) $post_sticky = $_POST['sticky'];
		else $post_sticky = null;
		$_sticky = ($dt['sticky'] == '1' || $post_sticky == '1') ? 'checked="checked"' : '';
		if(isforumadmin($userID) || ismoderator($userID, $dt['boardID'])) {
			$chk_sticky = '<br />'."\n".' <input class="input" type="checkbox" name="sticky" value="1" '.$_sticky.' /> '.$_language->module['make_sticky'];
		}
		else {
			$chk_sticky = '';
		}

		if(isset($_POST['notify'])) $post_notify = $_POST['notify'];
		else $post_notify = null;
		$mysql_notify = mysql_num_rows(safe_query("SELECT notifyID FROM ".PREFIX."forum_notify WHERE userID='".$userID."' AND topicID='".$topic."'"));
		$notify = ($mysql_notify || $post_notify == '1') ? 'checked="checked"' : '';


		$bg1=BG_1;
		$board = $dt['boardID'];

		eval ("\$addbbcode = \"".gettemplate("addbbcode")."\";");
		eval ("\$forum_newreply = \"".gettemplate("forum_newreply")."\";");
		echo $forum_newreply;
	}
	elseif($loggedin) {
		echo'<br /><br />'.$_language->module['no_access_write'].'<br /><br />';
	}
	else {
		echo $_language->module['not_logged_msg'];
	}
	$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=$_language->module['today'];
	elseif($date==$yesterday && $date<$today) $date=$_language->module['yesterday'];
	else $date=$date;

	$message = cleartext($dr['message']);
	$message = toggle($message, $dr['postID']);
	$postID = $dr['postID'];

	$username='<a href="index.php?site=profile&id='.$dr['poster'].'"><b>'.stripslashes(getnickname($dr['poster'])).'</b></a>';

	if(isclanmember($dr['poster'])) $member=' <img src="images/icons/member.gif" alt="'.$_language->module['clanmember'].'" />';
	else $member='';

	if($getavatar = getavatar($dr['poster'])) $avatar='<img src="images/avatars/'.$getavatar.'" alt="" />';
	else $avatar='';

	if($getsignatur = getsignatur($dr['poster'])) $signatur=cleartext($getsignatur);
	else $signatur='';

	if($getemail = getemail($dr['poster']) and !getemailhide($dr['poster'])) $email = '<a href="mailto:'.mail_protect($getemail).'"><img src="images/icons/email.gif" border="0" alt="email" /></a>';
	else $email='';

	$pm='';
	$buddy='';
	if($loggedin && $dr['poster']!=$userID) {
		$pm='<a href="index.php?site=messenger&action=touser&touser='.$dr['poster'].'"><img src="images/icons/pm.gif" border="0" width="12" height="13" alt="'.$_language->module['messenger'].'" /></a>';
		if(isignored($userID, $dr['poster'])) $buddy='<a href="buddys.php?action=readd&id='.$dr['poster'].'&userID='.$userID.'"><img src="images/icons/buddy_readd.gif" border="0" alt="'.$_language->module['back_buddy'].'" /></a>';
		elseif(isbuddy($userID, $dr['poster'])) $buddy='<a href="buddys.php?action=ignore&id='.$dr['poster'].'&userID='.$userID.'"><img src="images/icons/buddy_ignore.gif" border="0" alt="'.$_language->module['ignore'].'" /></a>';
		else $buddy='<a href="buddys.php?action=add&id='.$dr['poster'].'&userID='.$userID.'"><img src="images/icons/buddy_add.gif" border="0" alt="'.$_language->module['add_buddy'].'" /></a>';
	}

	if(isonline($dr['poster'])=="offline") $statuspic='<img src="images/icons/offline.gif" alt="offline" />';
	else $statuspic='<img src="images/icons/online.gif" alt="online" />';

	$sem = '^[http://]+[a-z0-9_\.-]+[a-z0-9_-]+$';
	if(!(eregi($sem, gethomepage($dr['poster'])))) $hp='';
	else $hp='<a href="'.gethomepage($dr['poster']).'" target="_blank"><img src="images/icons/hp.gif" border="0" alt="'.$_language->module['homepage'].'" /></a>';

	if(!$dt['closed']) $quote='<a href="index.php?site=forum_topic&addreply=true&board='.$dt['boardID'].'&topic='.$topic.'&quoteID='.$dr['postID'].'&page='.$page.'&type='.$type.'"><img src="images/icons/quote.gif" border="0" alt="'.$_language->module['quote'].'" /></a>';
	else $quote = "";

	$registered = getregistered($dr['poster']);

	$posts = getuserforumposts($dr['poster']);

	if(isforumadmin($dr['poster'])) {
		$usertype=$_language->module['admin'];
		$rang='<img src="images/icons/ranks/admin.gif" alt="" />';
	}
	elseif(isanymoderator($dr['poster'])) {
		$usertype=$_language->module['moderator'];
		$rang='<img src="images/icons/ranks/moderator.gif" alt="" />';
	} else {
		$ergebnis=safe_query("SELECT * FROM ".PREFIX."forum_ranks WHERE $posts >= postmin AND $posts <= postmax AND special='0'");
		$ds=mysql_fetch_array($ergebnis);
		$usertype=$ds['rank'];
		$rang='<img src="images/icons/ranks/'.$ds['pic'].'" alt="" />';
	}
	$specialrang = "";
	$specialtype = "";
	$position = "";
	$getrank = safe_query("SELECT IF(u.special_rank = 0, 0, CONCAT_WS(\"__\",r.rank, r.pic)) as RANK FROM ".PREFIX."user u LEFT JOIN ".PREFIX."forum_ranks r ON u.special_rank = r.rankID WHERE userID='".$dr['poster']."'");
                $getposition =    safe_query("SELECT IF(u.rank_position = 0, 0, CONCAT_WS(\"__\",r.rank, r.pic)) as POSITION FROM ".PREFIX."user u LEFT JOIN ".PREFIX."forum_ranks r ON u.rank_position = r.rankID WHERE userID='".$dr['poster']."'");
	$rank_data = mysql_fetch_assoc($getrank);
	$position_data =  mysql_fetch_assoc($getposition);


	if($rank_data['RANK'] != '0'){
		$tmp_rank = explode("__",$rank_data['RANK']);
		$specialrang = $tmp_rank[0];
                        $specialtype = '<img src="images/icons/ranks/'
                        .$tmp_rank[1].
                            '" alt = "'
                        .$specialrang.
                          '" />';

	}
if($position_data['POSITION'] != '0'){
		$tmp_position = explode("__",$position_data['POSITION']);
		$specialpos = $tmp_position[0];
                        $specialtypepos = '<img src="images/icons/ranks/'
                        .$tmp_position[1].
                              '" alt = "'
                        .$specialpos.
                          '" />';

	}



	$actions='';
	if(($userID == $dr['poster'] OR isforumadmin($userID) OR ismoderator($userID,$dt['boardID']))&& !$dt['closed']) $actions=' <a href="index.php?site=forum_topic&topic='.$topic.'&edit=true&id='.$dr['postID'].'&page='.$page.'"><img src="images/icons/edit.gif" border="0" alt="'.$_language->module['edit'].'" /></a> ';
	if(isforumadmin($userID) OR ismoderator($userID,$dt['boardID'])) $actions.='<input class="input" type="checkbox" name="postID[]" value="'.$dr['postID'].'" />';

	eval ("\$forum_topic_content = \"".gettemplate("forum_topic_content")."\";");
	echo $forum_topic_content;
	unset($actions);
	$i++;
}

$adminactions = "";
if(isforumadmin($userID) OR ismoderator($userID,$dt['boardID'])) {

	if($dt['closed']) $close='<option value="opentopic">- '.$_language->module['reopen_topic'].'</option>';
	else $close='<option value="closetopic">- '.$_language->module['close_topic'].'</option>';

	$adminactions='<input class="input" type="checkbox" name="ALL" value="ALL" onclick="SelectAll(this.form);" /> '.$_language->module['select_all'].'
	<select name="admaction">
      <option value="0">'.$_language->module['admin_actions'].':</option>
      <option value="delposts">- '.$_language->module['delete_posts'].'</option>
      <option value="stickytopic">- '.$_language->module['make_topic_sticky'].'</option>
      <option value="unstickytopic">- '.$_language->module['make_topic_unsticky'].'</option>
      <option value="movetopic">- '.$_language->module['move_topic'].'</option>
      '.$close.'
      <option value="deletetopic">- '.$_language->module['delete_topic'].'</option>
    </select>
    <input type="hidden" name="topicID" value="'.$topic.'" />
    <input type="hidden" name="board" value="'.$dt['boardID'].'" />
    <input type="submit" name="submit" value="'.$_language->module['go'].'" />';

}

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'<div align="right">'.$adminactions.'</div></form>';

if($dt['closed']) {
	echo $_language->module['closed_image'];
}
else {
	if(!$loggedin && !$edit) {
		echo $_language->module['not_logged_msg'];
	}
}
}

showtopic($topic, $edit, $addreply, $quoteID, $type);

?>

 

Continued in second post.....

 

Link to comment
Share on other sites

forum.php (lines of interest 968-990)

 

<?php


if(isset($_POST['board'])) $board = (int)$_POST['board'];
elseif(isset($_GET['board'])) $board = (int)$_GET['board'];
else $board = null;

if(!isset($_GET['page'])) $page = '';
else $page = (int)$_GET['page'];
if(!isset($_GET['action'])) $action = '';
else $action = $_GET['action'];

function forum_stats() {
$pagebg=PAGEBG;
$border=BORDER;
$bghead=BGHEAD;
$bgcat=BGCAT;
$bg1=BG_1;
global $wincolor;
global $loosecolor;
global $drawcolor;
global $_language;

$_language->read_module('forum');

// TODAY birthdays
$ergebnis=safe_query("SELECT nickname, userID, YEAR(CURRENT_DATE()) -YEAR(birthday) 'age' FROM ".PREFIX."user WHERE DATE_FORMAT(`birthday`, '%m%d') = DATE_FORMAT(NOW(), '%m%d')");
$n=0;
while($db=mysql_fetch_array($ergebnis)) {
	$n++;
	$years=$db['age'];
	if($n>1) $birthdays.=', <a href="index.php?site=profile&id='.$db['userID'].'"><b>'.$db['nickname'].'</b></a> ('.$years.')';
	else $birthdays='<a href="index.php?site=profile&id='.$db['userID'].'"><b>'.$db['nickname'].'</b></a> ('.$years.')';
}
if(!$n) $birthdays=$_language->module['n_a'];


// WEEK birthdays
$ergebnis=safe_query("SELECT nickname, userID, DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW()) - TO_DAYS(birthday)), '%y') + 1 AS age FROM ".PREFIX."user WHERE IF(DAYOFYEAR(NOW())<=358,((DAYOFYEAR(birthday)>DAYOFYEAR(NOW())) AND (DAYOFYEAR(birthday)<=DAYOFYEAR(DATE_ADD(NOW(), INTERVAL 7 DAY)))),(DAYOFYEAR(BIRTHDAY)>DAYOFYEAR(NOW()) OR DAYOFYEAR(birthday)<=DAYOFYEAR(DATE_ADD(NOW(), INTERVAL 7 DAY)))) AND birthday !='0000-00-00 00:00:00' ORDER BY `birthday` ASC");
$n=0;
while($db=mysql_fetch_array($ergebnis)) {
	$n++;
	$years=$db['age'];
	if($n>1) $birthweek.=', <a href="index.php?site=profile&id='.$db['userID'].'"><b>'.$db['nickname'].'</b></a> ('.$years.')';
	else $birthweek='<a href="index.php?site=profile&id='.$db['userID'].'"><b>'.$db['nickname'].'</b></a> ('.$years.')';
}
if(!$n) $birthweek=$_language->module['n_a'];

// WHOISONLINE
$guests = mysql_num_rows(safe_query("SELECT ip FROM ".PREFIX."whoisonline WHERE userID=''"));
$user = mysql_num_rows(safe_query("SELECT userID FROM ".PREFIX."whoisonline WHERE ip=''"));
$useronline = $guests + $user;

if($user==1) $user_on=$_language->module['registered_user'];
else $user_on=$user.' '.$_language->module['registered_users'];

if($guests==1) $guests_on=$_language->module['guest'];
else $guests_on= $guests.' '.$_language->module['guests'];

$ergebnis = safe_query("SELECT w.*, u.nickname FROM ".PREFIX."whoisonline w LEFT JOIN ".PREFIX."user u ON u.userID = w.userID  WHERE w.ip='' ORDER BY u.nickname");
$user_names = "";
if($user) {
	$n=1;
	while($ds=mysql_fetch_array($ergebnis)) {
		if(isforumadmin($ds['userID'])) $nickname = '<span style="color:'.$loosecolor.'">'.$ds['nickname'].'</span>';
		elseif(isanymoderator($ds['userID'])) $nickname = '<span style="color:'.$drawcolor.'">'.$ds['nickname'].'</span>';
		elseif(isclanmember($ds['userID'])) $nickname = '<span style="color:'.$wincolor.'">'.$ds['nickname'].'</span>';
      		else $nickname = $ds['nickname'];
		if($n>1) $user_names .= ', <a href="index.php?site=profile&id='.$ds['userID'].'"><b>'.$nickname.'</b></a>';
		else $user_names = '<a href="index.php?site=profile&id='.$ds['userID'].'"><b>'.$nickname.'</b></a>';
		$n++;
	}
}

$dt=mysql_fetch_array(safe_query("SELECT sum(topics) FROM ".PREFIX."forum_boards"));
$topics=$dt[0];
$dt=mysql_fetch_array(safe_query("SELECT sum(posts) FROM ".PREFIX."forum_boards"));
$posts=$dt[0];
$posts=$posts;
$dt=mysql_fetch_array(safe_query("SELECT count(userID) FROM ".PREFIX."user WHERE activated='1'"));
$registered=$dt[0];
$newestuser=safe_query("SELECT userID, nickname FROM ".PREFIX."user WHERE activated='1' ORDER BY registerdate DESC LIMIT 0,1");
$dn=mysql_fetch_array($newestuser);
$dm=mysql_fetch_array(safe_query("SELECT maxonline FROM ".PREFIX."counter"));
$maxonline=$dm['maxonline'];

$newestmember='<a href="index.php?site=profile&id='.$dn['userID'].'"><b>'.$dn['nickname'].'</b></a>';
eval ("\$forum_stats = \"".gettemplate("forum_stats")."\";");
echo $forum_stats;
}

function boardmain() {
global $maxposts;
global $userID;
global $action;
global $loggedin;
global $_language;
global $maxtopics;

$_language->read_module('forum');

$pagebg=PAGEBG;
$border=BORDER;
$bghead=BGHEAD;
$bgcat=BGCAT;

eval ("\$title_messageboard = \"".gettemplate("title_messageboard")."\";");
echo $title_messageboard;

if($action=="markall") {
	safe_query("UPDATE ".PREFIX."user SET topics='|' WHERE userID='$userID'");
}

eval ("\$forum_main_head = \"".gettemplate("forum_main_head")."\";");
echo $forum_main_head;

// KATEGORIEN
$sql_where = '';
if(isset($_GET['cat'])){
	if(is_numeric($_GET['cat'])){
		$sql_where = " WHERE catID='".$_GET['cat']."'";
	}
}
$kath=safe_query("SELECT catID, name, info, readgrps FROM ".PREFIX."forum_categories".$sql_where." ORDER BY sort");
while($dk=mysql_fetch_array($kath)) {
	$kathname = "<a href='index.php?site=forum&cat=".$dk['catID']."'>".$dk['name']."</a>";
	if($dk['info']) $info=$dk['info'];
	else $info='';

	if($dk['readgrps'] != "") {
		$usergrp = 0;
		$readgrps = explode(";", $dk['readgrps']);
		foreach($readgrps as $value) {
			if(isinusergrp($value, $userID)) {
				$usergrp = 1;
				break;
			}
		}

		if(!$usergrp) continue;
	}
	eval ("\$forum_main_kath = \"".gettemplate("forum_main_kath")."\";");
	echo $forum_main_kath;

	// BOARDS MIT KATEGORIE
	$boards=safe_query("SELECT * FROM ".PREFIX."forum_boards WHERE category='".$dk['catID']."' ORDER BY sort");
	$i=1;

	while($db=mysql_fetch_array($boards)) {

		if($i%2) {
			$bg1=BG_1;
			$bg2=BG_2;
		}
		else {
			$bg1=BG_3;
			$bg2=BG_4;
		}

		$ismod = ismoderator($userID, $db['boardID']);
		$usergrp = 0;
		$writer = 'ro-';
		if($db['writegrps'] != "" and !$ismod) {
			$writegrps = explode(";", $db['writegrps']);
			foreach($writegrps as $value) {
				if(isinusergrp($value, $userID)) {
					$usergrp = 1;
					$writer = '';
					break;
				}
			}
		}
		else $writer = '';
		if($db['readgrps'] != "" and !$usergrp and !$ismod) {
			$readgrps = explode(";", $db['readgrps']);
			foreach($readgrps as $value) {
				if(isinusergrp($value, $userID)) {
					$usergrp = 1;
					break;
				}
			}
			if(!$usergrp) continue;
		}

		$board=$db['boardID'];
		$anztopics=$db['topics'];
		$anzposts=$db['posts'];
		$boardname = $db['name'];
		$boardname ='&#8226; <a href="index.php?site=forum&board='.$board.'"><b>'.$boardname.'</b></a>';

		if($db['info']) $boardinfo=$db['info'];
		else $boardinfo='';
		$moderators=getmoderators($db['boardID']);
		if($moderators) $moderators=$_language->module['moderated_by'].': '.$moderators;

		$postlink='';
		$date='';
		$time='';
		$poster='';
		$member='';

		$q = safe_query("SELECT topicID, lastdate, lastposter, replys FROM ".PREFIX."forum_topics WHERE boardID='".$db['boardID']."' AND moveID='0' ORDER BY lastdate DESC LIMIT 0,".$maxtopics);
		$n=1;
		$board_topics = Array();
		while($lp = mysql_fetch_assoc($q)) {

			if($n == 1) {

				$date=date("d.m.Y", $lp['lastdate']);
				$today=date("d.m.Y", time());
				$yesterday = date("d.m.Y", time()-3600*24);

				if($date==$today) $date=$_language->module['today'];
				elseif($date==$yesterday && $date<$today) $date=$_language->module['yesterday'];
				else $date=$date;

				$time=date("- H:i", $lp['lastdate']);
				$poster='<a href="index.php?site=profile&id='.$lp['lastposter'].'">'.getnickname($lp['lastposter']).'</a>';
				if(isclanmember($lp['lastposter'])) $member=' <img src="images/icons/member.gif" alt="'.$_language->module['clanmember'].'" />';
				else $member='';
				$topic=$lp['topicID'];
				$postlink='index.php?site=forum_topic&topic='.$topic.'&type=ASC&page='.ceil(($lp['replys']+1)/$maxposts);

			}
			if($userID) $board_topics[] = $lp['topicID'];
			else break;
			$n++;				
		}

		// get unviewed topics

		$found = false;

		if($userID) {

			$gv=mysql_fetch_array(safe_query("SELECT topics FROM ".PREFIX."user WHERE userID='$userID'"));
			$array=explode("|", $gv['topics']);

			foreach($array as $split) {

				if($split != "" AND in_array($split, $board_topics)) {
						$found=true;
						break;
				}
			}
		}

		if($found) $icon='<img src="images/icons/boardicons/'.$writer.'on.gif" alt="'.$_language->module['new_posts'].'" />';
		else $icon='<img src="images/icons/boardicons/'.$writer.'off.gif" alt="'.$_language->module['no_new_posts'].'" />';


		eval ("\$forum_main_board = \"".gettemplate("forum_main_board")."\";");
		echo $forum_main_board;

		$i++;
	}
}

// BOARDS OHNE KATEGORIE
$boards=safe_query("SELECT * FROM ".PREFIX."forum_boards WHERE category='0' ORDER BY sort");
$i=1;
while($db=mysql_fetch_array($boards)) {

	if($i%2) {
		$bg1=BG_1;
		$bg2=BG_2;
	}
	else {
		$bg1=BG_3;
		$bg2=BG_4;
	}

	$usergrp = 0;
	$writer = 'ro-';
	$ismod = ismoderator($userID, $db['boardID']);
	if($db['writegrps'] != "" and !$ismod) {
		$writegrps = explode(";", $db['writegrps']);
		foreach($writegrps as $value) {
			if(isinusergrp($value, $userID)) {
				$usergrp = 1;
				$writer = '';
				break;
			}
		}
	}
	else $writer = '';
	if($db['readgrps'] != "" and !$usergrp and !$ismod) {
		$readgrps = explode(";", $db['readgrps']);
		foreach($readgrps as $value) {
			if(isinusergrp($value, $userID)) {
				$usergrp = 1;
				break;
			}
		}
		if(!$usergrp) continue;
	}

	$board=$db['boardID'];
	$anztopics=$db['topics'];
	$anzposts=$db['posts'];

	$boardname = $db['name'];
	$boardname='&#8226; <a href="index.php?site=forum&board='.$db['boardID'].'"><b>'.$boardname.'</b></a>';

	$boardinfo='';
	if($db['info']) $boardinfo=$db['info'];
	$moderators=getmoderators($db['boardID']);
	if($moderators) $moderators=$_language->module['moderated_by'].': '.$moderators;

		$q = safe_query("SELECT topicID, lastdate, lastposter, replys FROM ".PREFIX."forum_topics WHERE boardID='".$db['boardID']."' AND moveID='0' ORDER BY lastdate DESC LIMIT 0,".$maxtopics);
		$n=1;
		$board_topics = Array();
		while($lp = mysql_fetch_assoc($q)) {

			if($n == 1) {

				$date=date("d.m.Y", $lp['lastdate']);
				$today=date("d.m.Y", time());
				$yesterday = date("d.m.Y", time()-3600*24);

				if($date==$today) $date=$_language->module['today'];
				elseif($date==$yesterday && $date<$today) $date=$_language->module['yesterday'];
				else $date=$date;

				$time=date("- H:i", $lp['lastdate']);
				$poster='<a href="index.php?site=profile&id='.$lp['lastposter'].'">'.getnickname($lp['lastposter']).'</a>';
				if(isclanmember($lp['lastposter'])) $member=' <img src="images/icons/member.gif" alt="'.$_language->module['clanmember'].'" />';
				else $member='';
				$topic=$lp['topicID'];
				$postlink='index.php?site=forum_topic&topic='.$topic.'&type=ASC&page='.ceil(($lp['replys']+1)/$maxposts);

			}
			if($userID) $board_topics[] = $ds['topicID'];
			else break;
			$n++;				
		}

		// get unviewed topics

		$found = false;

		if($userID) {

			$gv=mysql_fetch_array(safe_query("SELECT topics FROM ".PREFIX."user WHERE userID='$userID'"));
			$array=explode("|", $gv['topics']);

			foreach($array as $split) {

				if($split != "" AND in_array($split, $board_topics)) {
						$found=true;
						break;
				}
			}
		}

		if($found) $icon='<img src="images/icons/boardicons/'.$writer.'on.gif" alt="'.$_language->module['new_posts'].'" />';
		else $icon='<img src="images/icons/boardicons/'.$writer.'off.gif" alt="'.$_language->module['no_new_posts'].'" />';

	eval ("\$forum_main_board = \"".gettemplate("forum_main_board")."\";");
	echo $forum_main_board;

	$i++;
}

eval ("\$forum_main_foot = \"".gettemplate("forum_main_foot")."\";");
echo $forum_main_foot;

if($loggedin) {
	eval ("\$forum_main_legend = \"".gettemplate("forum_main_legend")."\";");
	echo $forum_main_legend;
}


forum_stats();
}

function showboard($board) {
global $userID;
global $loggedin;
global $maxtopics;
global $maxposts;
global $page;
global $action;
global $_language;

$_language->read_module('forum');

$pagebg=PAGEBG;
$border=BORDER;
$bghead=BGHEAD;
$bgcat=BGCAT;

eval ("\$title_messageboard = \"".gettemplate("title_messageboard")."\";");
echo $title_messageboard;

$alle = safe_query("SELECT topicID FROM ".PREFIX."forum_topics WHERE boardID='$board'");
$gesamt=mysql_num_rows($alle);

if($action=="markall" AND $userID) {
	$gv=mysql_fetch_array(safe_query("SELECT topics FROM ".PREFIX."user WHERE userID='$userID'"));

	$board_topics = Array();
	while($ds=mysql_fetch_array($alle))	$board_topics[] = $ds['topicID'];

	$array=explode("|", $gv['topics']);
	$new='|';

	foreach($array as $split) {
		if($split != "" AND !in_array($split, $board_topics)) $new .= $split.'|';
	}

	safe_query("UPDATE ".PREFIX."user SET topics='".$new."' WHERE userID='$userID'");
}

if(!isset($page) || $page=='') $page=1;
$max=$maxtopics;
$pages=ceil($gesamt/$max);

$page_link = '';
if($pages>1) $page_link = makepagelink("index.php?site=forum&board=$board", $page, $pages);

if($page==1) $start=0;
if($page>1) $start=$page*$max-$max;

$db = mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."forum_boards WHERE boardID='".$board."' "));
$boardname = $db['name'];

$usergrp = 0;
$writer = 0;

$ismod=false;
if(ismoderator($userID, $board) OR isforumadmin($userID)) $ismod = true;

if($db['writegrps'] != "" and !$ismod) {
	$writegrps = explode(";", $db['writegrps']);
	foreach($writegrps as $value) {
		if(isinusergrp($value, $userID)) {
			$usergrp = 1;
			$writer = 1;
			break;
		}
	}
}
else $writer = 1;
if($db['readgrps'] != "" and !$usergrp and !$ismod) {
	$readgrps = explode(";", $db['readgrps']);
	foreach($readgrps as $value) {
		if(isinusergrp($value, $userID)) {
			$usergrp = 1;
			break;
		}
	}
	if(!$usergrp){
		echo $_language->module['no_permission'];
		redirect('index.php?site=forum','',2);
		return;
	}
}

$moderators=getmoderators($board);
if($moderators) $moderators='('.$_language->module['moderated_by'].': '.$moderators.')';

$actions='<a href="index.php?site=search">'.$_language->module['search_image'].'</a>';
if($loggedin) {
	$mark='&#8226; <a href="index.php?site=forum&board='.$board.'&action=markall">'.$_language->module['mark_topics_read'].'</a>';
	if($writer) $actions.=' <a href="index.php?site=forum&addtopic=true&board='.$board.'">'.$_language->module['newtopic_image'].'</a>';
} else $mark='';

$cat = $db['category'];
$kathname = getcategoryname($cat);
eval ("\$forum_head = \"".gettemplate("forum_head")."\";");
echo $forum_head;

// TOPICS

$i=1;
$topics = safe_query("SELECT * FROM ".PREFIX."forum_topics WHERE boardID='$board' ORDER BY sticky DESC, lastdate DESC LIMIT $start,$max");
$anztopics = mysql_num_rows(safe_query("SELECT boardID FROM ".PREFIX."forum_topics WHERE boardID='$board'"));

$i=1;
unset($link);
if($anztopics) {
	eval ("\$forum_topics_head = \"".gettemplate("forum_topics_head")."\";");
	echo $forum_topics_head;
	while($dt=mysql_fetch_array($topics)) {
		if($i%2) {
			$bg1=BG_1;
			$bg2=BG_2;
		}
		else {
			$bg1=BG_3;
			$bg2=BG_4;
		}

		if($dt['moveID']) $gesamt=0;
		else $gesamt=$dt['replys']+1;

		$topicpages=1;
		$topicpages=ceil($gesamt/$maxposts);

		$topicpage_link = '';
		if($topicpages>1) $topicpage_link = makepagelink("index.php?site=forum_topic&topic=".$dt['topicID'], 1, $topicpages);

		if($dt['icon']) $icon='<img src="images/icons/topicicons/'.$dt['icon'].'" alt="" />';
		else $icon='';

		// viewed topics

		if($dt['sticky']) {
			$onicon = '<img src="images/icons/foldericons/newsticky.gif" alt="'.$_language->module['sticky'].'" />';
			$officon = '<img src="images/icons/foldericons/sticky.gif" alt="'.$_language->module['sticky'].'" />';
			$onhoticon = '<img src="images/icons/foldericons/newsticky.gif" alt="'.$_language->module['sticky'].'" />';
			$offhoticon = '<img src="images/icons/foldericons/sticky.gif" alt="'.$_language->module['sticky'].'" />';
		}
		else {
			$onicon = '<img src="images/icons/foldericons/newfolder.gif" alt="'.$_language->module['new_posts'].'" />';
			$officon = '<img src="images/icons/foldericons/folder.gif" alt="no '.$_language->module['new_posts'].'" />';
			$onhoticon = '<img src="images/icons/foldericons/newhotfolder.gif" alt="'.$_language->module['new_posts'].' ['.$_language->module['popular'].']" />';
			$offhoticon = '<img src="images/icons/foldericons/hotfolder.gif" alt="no '.$_language->module['new_posts'].' ['.$_language->module['popular'].']" />';
		}

		if($dt['closed']) $folder='<img src="images/icons/foldericons/lockfolder.gif" alt="'.$_language->module['closed'].'" />';
		elseif($dt['moveID']) $folder='<img src="images/icons/topicicons/pfeil.gif" alt="'.$_language->module['moved'].'" />';
		elseif($userID) {

			$is_unread = mysql_num_rows(safe_query("SELECT userID FROM ".PREFIX."user WHERE topics LIKE '%|".$dt['topicID']."|%' AND userID='".$userID."'"));

			if($is_unread) {
				if($dt['replys']>15 || $dt['views']>150) $folder=$onhoticon;
				else $folder=$onicon;
			}
			else {
				if($dt['replys']>15 || $dt['views']>150) $folder=$offhoticon;
				else $folder=$officon;
			}
		}
		else {
			if($gesamt>15) $folder=$offhoticon;
			else $folder=$officon;
		}
		// end viewed topics

		$topictitle=getinput($dt['topic']);
		$topictitle=str_break($topictitle, 40);

		$poster='<a href="index.php?site=profile&id='.$dt['userID'].'">'.getnickname($dt['userID']).'</a>';
		if(isset($posterID) and isclanmember($posterID)) $member1=' <img src="images/icons/member.gif" alt="'.$_language->module['clanmember'].'" />';
		else $member1='';

		$replys='0';
		$views='0';

		if($dt['moveID']) { // MOVED TOPIC
			$move=safe_query("SELECT * FROM ".PREFIX."forum_topics WHERE topicID='".$dt['moveID']."'");
			$dm=mysql_fetch_array($move);

			if($dm['replys']) $replys=$dm['replys'];
			if($dm['views']) $views=$dm['views'];

			$date=date("d.m.y", $dm['lastdate']);
			$time=date("H:i", $dm['lastdate']);
			$today=date("d.m.y", time());
			$yesterday = date("d.m.y", time()-3600*24);
			if($date==$today) $date=$_language->module['today'].", ".$time;
			elseif($date==$yesterday && $date<$today) $date=$_language->module['yesterday'].", ".$time;
			else $date=$date.", ".$time;
			$lastposter='<a href="index.php?site=profile&id='.$dm['lastposter'].'">'.getnickname($dm['lastposter']).'</a>';
			if(isclanmember($dm['lastposter'])) $member=' <img src="images/icons/member.gif" alt="'.$_language->module['clanmember'].'" />';
			else $member='';
			$link='<a href="index.php?site=forum_topic&topic='.$dt['moveID'].'"><b>'.$_language->module['moved'].': '.$topictitle.'</b></a>';

		}
		else {	// NO MOVED TOPIC
			if($dt['replys']) $replys=$dt['replys'];
			if($dt['views']) $views=$dt['views'];

			$date=date("d.m.y", $dt['lastdate']);
			$time=date("H:i", $dt['lastdate']);
			$today=date("d.m.y", time());
			$yesterday = date("d.m.y", time()-3600*24);
			if($date==$today) $date=$_language->module['today'].", ".$time;
			elseif($date==$yesterday && $date<$today) $date=$_language->module['yesterday'].", ".$time;
			else $date=$date.", ".$time;
			$lastposter='<a href="index.php?site=profile&id='.$dt['lastposter'].'">'.getnickname($dt['lastposter']).'</a>';
			if(isclanmember($dt['lastposter'])) $member=' <img src="images/icons/member.gif" alt="'.$_language->module['clanmember'].'" />';
			else $member='';
			$link='<a href="index.php?site=forum_topic&topic='.$dt['topicID'].'"><b>'.$topictitle.'</b></a>';
		}

		eval ("\$forum_topics_content = \"".gettemplate("forum_topics_content")."\";");
		echo $forum_topics_content;
		$i++;
		unset($topicpage_link);
		unset($lastposter);
		unset($member);
		unset($member1);
		unset($date);
		unset($time);
		unset($link);

	}
	eval ("\$forum_topics_foot = \"".gettemplate("forum_topics_foot")."\";");
	echo $forum_topics_foot;

}

eval ("\$forum_actions = \"".gettemplate("forum_actions")."\";");
echo $forum_actions;

if($loggedin) {
	eval ("\$forum_topics_legend = \"".gettemplate("forum_topics_legend")."\";");
	echo $forum_topics_legend;
}

if(!$loggedin) echo $_language->module['not_logged_msg'];

unset($page_link);
}

if(isset($_POST['submit']) || isset($_POST['movetopic']) || isset($_GET['addtopic']) || isset($_POST['addtopic']) || (isset($_GET['action']) and $_GET['action'] == "admin-action") || isset($_POST['admaction'])) {

if(!isset($_POST['admaction'])) $_POST['admaction'] = '';

if($_POST['admaction']=="closetopic") {
	include("_mysql.php");
	include("_settings.php");
	include('_functions.php');
	$_language->read_module('forum');

	$topicID = (int)$_POST['topicID'];
	$board = (int)$_POST['board'];

	if(!isforumadmin($userID) and !ismoderator($userID, $board)) die($_language->module['no_access']);

	safe_query("UPDATE ".PREFIX."forum_topics SET closed='1' WHERE topicID='$topicID' ");
	header("Location: index.php?site=forum&board=$board");
}
elseif($_POST['admaction']=="opentopic") {
	include("_mysql.php");
	include("_settings.php");
	include('_functions.php');
	$_language->read_module('forum');

	$topicID = (int)$_POST['topicID'];
	$board = (int)$_POST['board'];

	if(!isforumadmin($userID) and !ismoderator($userID, $board)) die($_language->module['no_access']);

	safe_query("UPDATE ".PREFIX."forum_topics SET closed='0' WHERE topicID='$topicID' ");
	header("Location: index.php?site=forum&board=$board");
}
elseif($_POST['admaction']=="deletetopic") {
	include("_mysql.php");
	include("_settings.php");
	include('_functions.php');
	$_language->read_module('forum');

	$topicID = (int)$_POST['topicID'];
	$board = (int)$_POST['board'];

	if(!isforumadmin($userID) and !ismoderator($userID, $board)) die($_language->module['no_access']);

	$numposts = mysql_num_rows(safe_query("SELECT postID FROM ".PREFIX."forum_posts WHERE topicID='".$topicID."'"));
	$numposts --;

	safe_query("UPDATE ".PREFIX."forum_boards SET topics=topics-1, posts=posts-".$numposts." WHERE boardID='".$board."' ");
	safe_query("DELETE FROM ".PREFIX."forum_topics WHERE topicID='$topicID' ");
	safe_query("DELETE FROM ".PREFIX."forum_topics WHERE moveID='$topicID' ");
	safe_query("DELETE FROM ".PREFIX."forum_posts WHERE topicID='$topicID' ");
	header("Location: index.php?site=forum&board=$board");
}
elseif($_POST['admaction']=="stickytopic") {
	include("_mysql.php");
	include("_settings.php");
	include('_functions.php');
	$_language->read_module('forum');

	$topicID = (int)$_POST['topicID'];
	$board = (int)$_POST['board'];

	if(!isforumadmin($userID) and !ismoderator($userID, $board)) die($_language->module['no_access']);

	safe_query("UPDATE ".PREFIX."forum_topics SET sticky='1' WHERE topicID='$topicID' ");
	header("Location: index.php?site=forum&board=$board");
}
elseif($_POST['admaction']=="unstickytopic") {
	include("_mysql.php");
	include("_settings.php");
	include('_functions.php');
	$_language->read_module('forum');

	$topicID = (int)$_POST['topicID'];
	$board = (int)$_POST['board'];

	if(!isforumadmin($userID) and !ismoderator($userID, $board)) die($_language->module['no_access']);

	safe_query("UPDATE ".PREFIX."forum_topics SET sticky='0' WHERE topicID='$topicID' ");
	header("Location: index.php?site=forum&board=$board");
}
elseif($_POST['admaction']=="delposts") {
	include("_mysql.php");
	include("_settings.php");
	include('_functions.php');
	$_language->read_module('forum');

	$topicID = (int)$_POST['topicID'];
	if(isset($_POST['postID']))$postID = $_POST['postID'];
	else $postID = array();
	$board = (int)$_POST['board'];

	if(!isforumadmin($userID) and !ismoderator($userID, $board)) die($_language->module['no_access']);
	$last = safe_query("SELECT * FROM ".PREFIX."forum_posts WHERE topicID = '$topicID' ");
	$anz = mysql_num_rows($last);
	$deleted = false;
	foreach($postID as $id) {
		if($anz > 1) {
			safe_query("DELETE FROM ".PREFIX."forum_posts WHERE postID='".(int)$id."' ");
			safe_query("UPDATE ".PREFIX."forum_boards SET posts=posts-1 WHERE boardID='".$board."' ");
			$last = safe_query("SELECT * FROM ".PREFIX."forum_posts WHERE topicID = '$topicID' ORDER BY date DESC LIMIT 0,1 ");
			$dl = mysql_fetch_array($last);
			safe_query("UPDATE ".PREFIX."forum_topics SET lastdate='".$dl['date']."', lastposter='".$dl['poster']."', lastpostID='".$ds['postID']."', replys=replys-1 WHERE topicID='$topicID' ");
			$deleted=false;
		}
		else {
			safe_query("DELETE FROM ".PREFIX."forum_posts WHERE postID='".(int)$id."' ");
			safe_query("DELETE FROM ".PREFIX."forum_topics WHERE topicID='$topicID' OR moveID='$topicID'");
			safe_query("UPDATE ".PREFIX."forum_boards SET topics=topics-1 WHERE boardID='".$board."' ");
			$deleted=true;
		}
	}
	if($deleted) header("Location: index.php?site=forum&board=$board");
	else header("Location: index.php?site=forum_topic&topic=$topicID");
}
elseif(isset($_POST['movetopic'])) {
	include("_mysql.php");
	include("_settings.php");
	include('_functions.php');
	$_language->read_module('forum');

	$toboard = (int)$_POST['toboard'];
	$topicID = (int)$_POST['topicID'];

	if(!isanyadmin($userID) and !ismoderator($userID, getboardid($topicID))) die($_language->module['no_access']);

	$di=mysql_fetch_array(safe_query("SELECT writegrps, readgrps FROM ".PREFIX."forum_boards WHERE boardID='$toboard'"));

	$ergebnis=safe_query("SELECT * FROM ".PREFIX."forum_topics WHERE topicID='$topicID'");
	$ds=mysql_fetch_array($ergebnis);

	if(isset($_POST['movelink']) and $ds['boardID'] != $toboard) safe_query("INSERT INTO ".PREFIX."forum_topics (boardID, icon, userID, date, topic, lastdate, lastposter, replys, views, closed, moveID) values ('".$ds['boardID']."', '', '".$ds['userID']."', '".$ds['date']."', '".addslashes($ds['topic'])."', '".$ds['lastdate']."', '', '', '', '', '$topicID') ");

	safe_query("UPDATE ".PREFIX."forum_topics SET boardID='$toboard', readgrps='".$di['readgrps']."', writegrps='".$di['writegrps']."' WHERE topicID='$topicID'");
	safe_query("UPDATE ".PREFIX."forum_posts SET boardID='$toboard' WHERE topicID='$topicID'");
	$post_num = mysql_affected_rows()-1;
	safe_query("UPDATE ".PREFIX."forum_boards SET topics=topics+1 WHERE boardID='$toboard'");
	safe_query("UPDATE ".PREFIX."forum_boards SET topics=topics-1 WHERE boardID='".$ds['boardID']."'");
	safe_query("UPDATE ".PREFIX."forum_boards SET posts=posts+".$post_num." WHERE boardID='".$toboard."'");
	safe_query("UPDATE ".PREFIX."forum_boards SET posts=posts-".$post_num." WHERE boardID='".$ds['boardID']."'");

	header("Location: index.php?site=forum&board=$toboard");
}
elseif($_POST['admaction']=="movetopic") {
	include("_mysql.php");
	include("_settings.php");
	include('_functions.php');
	$_language->read_module('forum');
	if(!isanyadmin($userID) and !ismoderator($userID, getboardid($_POST['topicID']))) die($_language->module['no_access']);

	$boards='';
	$kath=safe_query("SELECT * FROM ".PREFIX."forum_categories ORDER BY sort");
	while($dk=mysql_fetch_array($kath)) {
		$ergebnis=safe_query("SELECT * FROM ".PREFIX."forum_boards WHERE category='$dk[catID]' ORDER BY sort");
		while($db=mysql_fetch_array($ergebnis)) {
			$boards.='<option value="'.$db['boardID'].'">'.$dk['name'].' - '.$db['name'].'</option>';
		}
	}

	$ergebnis=safe_query("SELECT * FROM ".PREFIX."forum_boards WHERE category='0' ORDER BY sort");
	while($ds=mysql_fetch_array($ergebnis)) {
		$boards.='<option value="'.$ds['boardID'].'">'.$ds['name'].'</option>';
	}

	$pagetitle = PAGETITLE;
	$pagebg = PAGEBG;
	$border = BORDER;
	$bghead = BGHEAD;
	$bg1 = BG_1;

	$_language->read_module('forum');

	eval ("\$forum_move_topic = \"".gettemplate("forum_move_topic")."\";");
	echo $forum_move_topic;
}
elseif(isset($_POST['newtopic']) && $_POST['preview']!=1) {
	include("_mysql.php");
	include("_settings.php");
	include('_functions.php');
	$_language->read_module('forum');
	$_language->read_module('bbcode', true);

	if(!$userID) die($_language->module['not_logged']);

	$board = (int)$_POST['board'];
	if(boardexists($board)){
		if(isset($_POST['icon'])){
			$icon = $_POST['icon'];
			if(file_exists("images/icons/topicicons/".$icon)) $icon = $icon;
			else $icon = "";
		}
		else $icon = '';
		$topicname = $_POST['topicname']; if(!$topicname) $topicname = $_language->module['default_topic_title'];
		$message = $_POST['message'];
		$topic_sticky = (isset($_POST['sticky'])) ? '1' : '0';
		$notify = (isset($_POST['notify'])) ? '1' : '0';

		$ds=mysql_fetch_array(safe_query("SELECT readgrps, writegrps FROM ".PREFIX."forum_boards WHERE boardID='$board'"));

		$writer = 0;
		if($ds['writegrps'] != "") {
			$writegrps = explode(";", $ds['writegrps']);
			foreach($writegrps as $value) {
				if(isinusergrp($value, $userID)) {
					$writer = 1;
					break;
				}
			}
			if(ismoderator($userID, $board)) $writer = 1;
		}
		else $writer = 1;
		if(!$writer) die($_language->module['no_access_write']);

		$date=time();
		safe_query("INSERT INTO ".PREFIX."forum_topics ( boardID, readgrps, writegrps, userID, date, icon, topic, lastdate, lastposter, replys, views, closed, sticky ) values ( '$board', '".$ds['readgrps']."', '".$ds['writegrps']."', '$userID', '$date', '".$icon."', '".$topicname."', '$date', '$userID', '0', '0', '0', '$topic_sticky' ) ");
		$id=mysql_insert_id();
		safe_query("UPDATE ".PREFIX."forum_boards SET topics=topics+1 WHERE boardID='".$board."'");
		safe_query("INSERT INTO ".PREFIX."forum_posts ( boardID, topicID, date, poster, message ) values( '$board', '$id', '$date', '$userID', '".$message."' ) ");

		// check if there are more than 1000 unread topics => delete oldest one
		$dv = safe_query("SELECT topics FROM ".PREFIX."user WHERE userID='".$userID."'");
		$array = explode('|', $dv['topics']);
		if(count($array)>=1000) safe_query("UPDATE ".PREFIX."user SET topics='|".implode('|', array_slice($array, 2))."' WHERE userID='".$userID."'");
		unset($array);

		safe_query("UPDATE ".PREFIX."user SET topics=CONCAT(topics, '".$id."|')"); // update unread topics, format: |oldstring| => |oldstring|topicID|

		if($notify) safe_query("INSERT INTO ".PREFIX."forum_notify (topicID, userID) VALUES ('$id', '$userID') ");
		header("Location: index.php?site=forum&board=".$board."");
	}
	else{
		header("Location: index.php?site=forum");
	}		
}
elseif(isset($_REQUEST['addtopic'])) {
	$_language->read_module('forum');
	$_language->read_module('bbcode', true);

	eval ("\$title_messageboard = \"".gettemplate("title_messageboard")."\";");
	echo $title_messageboard;

	$ergebnis = safe_query("SELECT * FROM ".PREFIX."forum_boards WHERE boardID='$board' ");
	$db = mysql_fetch_array($ergebnis);
	$boardname = $db['name'];

	$writer = 0;
	if($db['writegrps'] != "") {
		$writegrps = explode(";", $db['writegrps']);
		foreach($writegrps as $value) {
			if(isinusergrp($value, $userID)) {
				$writer = 1;
				break;
			}
		}
		if(ismoderator($userID, $board)) $writer = 1;
	}
	else $writer = 1;
	if(!$writer) die($_language->module['no_access_write']);

	$moderators='';
	$cat = $db['category'];
	$kathname = getcategoryname($cat);

	eval ("\$forum_head = \"".gettemplate("forum_head")."\";");
	echo $forum_head;

	$bg1=BG_1;

	$message = '';

	if($loggedin) {
		if(isset($_POST['preview'])) {

			$bg1=BG_1;
			$bg2=BG_2;


			$time=date("H:i", time());
			$date="today";
			$message = cleartext(stripslashes(str_replace(array('\r\n', '\n'),array("\n","\n" ), $_POST['message'])));
			$message = toggle($message, 'xx');
			$username='<a href="index.php?site=profile&id='.$userID.'"><b>'.getnickname($userID).'</b></a>';

			$board = (int)$_POST['board'];
			$topicname = stripslashes($_POST['topicname']);
			if(!isset($postID)) $postID = '';

			if(isclanmember($userID)) $member=' <img src="images/icons/member.gif" alt="'.$_language->module['clanmember'].'" />';
			else $member='';
			if(getavatar($userID)) $avatar='<img src="images/avatars/'.getavatar($userID).'" alt="" />';
			else $avatar='';
			if(getsignatur($userID)) $signatur=cleartext(getsignatur($userID));
			else $signatur='';
			if(getemail($userID) and !getemailhide($userID)) $email = '<a href="mailto:'.mail_protect(getemail($userID)).'"><img src="images/icons/email.gif" border="0" alt="email" /></a>';
			else $email='';
			$pm='';
			$buddy='';
			$statuspic='<img src="images/icons/online.gif" width="7" height="7" alt="online" />';
			$sem = '^[http://]+[a-z0-9_\.-]+[a-z0-9_-]+$';
			if(!(eregi($sem, gethomepage($userID)))) $hp='';
			else $hp='<a href="'.gethomepage($userID).'" target="_blank"><img src="images/icons/hp.gif" border="0" width="14" height="14" alt="'.$_language->module['homepage'].'" /></a>';
			$registered = getregistered($userID);
			$posts = getuserforumposts($userID);
			if(isforumadmin($userID) || ismoderator($userID, $board)) {
				if(ismoderator($userID, $board)) {
					$usertype=$_language->module['moderator'];
					$rang='<img src="images/icons/ranks/moderator.gif" alt="" />';
					if(isset($_POST['sticky'])){
						$_sticky = 'checked="checked"';
					}
				}
				if(isforumadmin($userID)) {
					$usertype="Administrator";
					$rang='<img src="images/icons/ranks/admin.gif" alt="" />';
					if(isset($_POST['sticky'])){
						$_sticky = 'checked="checked"';
					}
				}
			}
			else {
				$ergebnis=safe_query("SELECT * FROM ".PREFIX."forum_ranks WHERE $posts >= postmin AND $posts <= postmax AND special='0'");
				$ds=mysql_fetch_array($ergebnis);
				$usertype=$ds['rank'];
				$rang='<img src="images/icons/ranks/'.$ds['pic'].'" alt="" />';
			}
			$specialrang = "";
			$specialtype = "";
			$specialpos = "";
			$specialtypepos = "";
			$getrank = safe_query("SELECT IF(u.special_rank = 0, 0, CONCAT_WS(\"__\",r.rank, r.pic)) as RANK FROM ".PREFIX."user u LEFT JOIN ".PREFIX."forum_ranks r ON u.special_rank = r.rankID WHERE userID='".$userID."'");
			$getposition =  safe_query("SELECT IF(u.rank_position = 0, 0, CONCAT_WS(\"__\",r.rank, r.pic)) as POSITION FROM ".PREFIX."user u LEFT JOIN ".PREFIX."forum_ranks r ON u.rank_position = r.rankID WHERE userID='".$userID."'");
			$rank_data = mysql_fetch_assoc($getrank);
			$position_data = mysql_fetch_assoc($getposition);

				if($rank_data['RANK'] != '0'){
		$tmp_rank = explode("__",$rank_data['RANK']);
		$specialrang = $tmp_rank[0];
                        $specialtype = '<img src="images/icons/ranks/'
                        .$tmp_rank[1].
                              '" alt = "'
                        .$specialrang.
                          '" />';

	}
			    if($position_data['POSITION'] != '0'){
		$tmp_position = explode("__",$position_data['POSITION']);
		$specialpos = $tmp_position[0];
                        $specialtypepos = '<img src="images/icons/ranks/'
                        .$tmp_position[1].
                             '" alt = "'
                        .$specialpos.
                         '" />';

	}

			$actions = '';
			$quote = '';

			echo'<table width="100%" cellspacing="1" cellpadding="2" bgcolor="'.BORDER.'">
          <tr bgcolor="'.BGHEAD.'">
            <td colspan="2" class="title" align="center">'.cleartext($topicname).'</td>
          </tr>
          <tr bgcolor="'.PAGEBG.'"><td colspan="2"></td></tr>';

			eval ("\$forum_topic_content = \"".gettemplate("forum_topic_content")."\";");
			echo $forum_topic_content;

        	echo'</table>';
        	
        	
		}
		else{
			$topicname = "";
		}

		eval ("\$addbbcode = \"".gettemplate("addbbcode")."\";");

		if(isforumadmin($userID) || ismoderator($userID, $board)) {
			if(isset($_sticky)){
				$chk_sticky = '<br />'."\n".' <input class="input" type="checkbox" name="sticky" value="1" '.$_sticky.' /> '.$_language->module['make_sticky'];
			}
			else {
				$chk_sticky = '<br />'."\n".' <input class="input" type="checkbox" name="sticky" value="1" /> '.$_language->module['make_sticky'];
			}
		}
		else {
			$chk_sticky = '';
		}
		if(isset($_POST['notify'])){
			$notify = ' checked="checked"';
		}
		else {
			$notify = '';
		}
		if(isset($_POST['topicname'])){
			$topicname=getforminput($_POST['topicname']);
		}
		if(isset($_POST['message'])){
			$message = getforminput($_POST['message']);
		}
		eval ("\$forum_newtopic = \"".gettemplate("forum_newtopic")."\";");
		echo $forum_newtopic;
	}
	else {
		echo $_language->module['not_logged_msg'];
	}
}
elseif(!$_POST['admaction']) {
	header("Location: index.php?site=forum");
}

}
elseif(!isset($board)) {
boardmain();
}
else showboard($board);

?>

 

forum_topic_content.html (lines of interest: all)

 

<tr>
  <td bgcolor="$bg1" width="125" valign="top">
  <table width="100%" cellpadding="2" cellspacing="0">
    <tr>
      <td align="center">$username $member</td>
    </tr>
    <tr>
      <td align="center"><small>$usertype</small></td>
    </tr>
    <tr>
    <td align="center"><hr></td>
    </tr>
    <tr>
      <td align="center"><small>$specialrang$specialtype</small></td>
    </tr>
     <tr>
      <td align="center"><small>$specialpos$specialtypepos</small></td>
    </tr>
    <tr>
      <td align="center">$avatar</td>
    </tr>
    <tr>
      <td align="center">$rang</td>
    </tr>
    <tr>
      <td align="center"><small>$posts %posts%</small></td>
    </tr>
    <tr>
      <td align="center"><small>%registered%: $registered</small></td>
    </tr>
  </table>
       <td bgcolor="$bg2" valign="top">
  <table width="100%" cellpadding="2" cellspacing="0">
    <tr>
      <td><a name="$postID" href="#$postID"><img src="images/icons/posticon.gif" width="10" height="11" alt="" /></a> <i>$date, $time</i> $pm $buddy $email $hp $statuspic</td>
      <td align="right"> $quote$actions </td>
    </tr>
  </table>
  <hr width="50%" />
  <div style="overflow:hidden;">$message</div>
  <hr width="90%" />
  <small>$signatur</small>  </td>
</tr>
<tr><td colspan="2" bgcolor="$pagebg"></td></tr>

 

Continued on third post....

 

Link to comment
Share on other sites

Here is a print out of the HTML page source from the image I showed you above with the copying of rank images:

 

page source

 

<table width="100%" cellpadding="2" cellspacing="0">
    <tr>
      <td align="center"><a href="index.php?site=profile&id=13"><b>CaptBrent</b></a>  <img src="images/icons/member.gif" alt="Clanmember" /></td>
    </tr>
    <tr>
      <td align="center"><small>Administrator</small></td>
    </tr>
    <tr>
    <td align="center"><hr></td>
    </tr>
    <tr>
      <td align="center"><small>general of the army<img src="images/icons/ranks/79.png" alt = "general of the army" /></small></td>
    </tr>
     <tr>
      <td align="center"><small>sos<img src="images/icons/ranks/82.png" alt = "sos" /></small></td>
    </tr>
    <tr>
      <td align="center"><img src="images/avatars/13.jpg" alt="" /></td>
    </tr>
    <tr>
      <td align="center"><img src="images/icons/ranks/admin.gif" alt="" /></td>
    </tr>
    <tr>
      <td align="center"><small>119 Posts</small></td>
    </tr>
    <tr>
      <td align="center"><small>registered: 28.03.2012</small></td>
    </tr>
  </table>


<table width="100%" cellpadding="2" cellspacing="0">
    <tr>
      <td align="center"><a href="index.php?site=profile&id=8"><b>CKuWiY2</b></a>  <img src="images/icons/member.gif" alt="Clanmember" /></td>
    </tr>
    <tr>
      <td align="center"><small> </small></td>
    </tr>
    <tr>
    <td align="center"><hr></td>
    </tr>
    <tr>
      <td align="center"><small>No Rank<img src="images/icons/ranks/45.png" alt = "No Rank" /></small></td>
    </tr>
     // beginning here, the code should not be displayed as the user has no rank defined (special_rank = 0)
<tr>
      <td align="center"><small>sos<img src="images/icons/ranks/82.png" alt = "sos" /></small></td>  //this should not be 82..
    </tr>
// end where code should be resumed for users without a rank defined..
    <tr>
      <td align="center"><img src="images/avatars/8.jpg" alt="" /></td>
    </tr>
    <tr>
      <td align="center"><img src="images/icons/ranks/13.gif" alt="" /></td>
    </tr>
    <tr>
      <td align="center"><small>869 Posts</small></td>
    </tr>
    <tr>
      <td align="center"><small>registered: 27.03.2012</small></td>
    </tr>
  </table>

 

 

Any insight into this will be GREATLY appreciated!

Link to comment
Share on other sites

I just had to set blank variables for those with rank or position 0 and it resolved it.

 

Added code to forum and forum_topic, printview.php

 

elseif ($rank_data['RANK'] == '0'){
                  
                  // blank data, no code sent

		$specialrang = "";
                        $specialtype = "";

  }

elseif ($position_data['POSITION'] == '0'){
                  
                  // blank data, no code sent

		$specialpos = ""  ;
                        $specialtypepos = "";
                  
  }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.