<?php
/*
 ########################################################################
#                                                                        #
#           Version 4       /                        /   /               #
#          -----------__---/__---__------__----__---/---/-               #
#           | /| /  /___) /   ) (_ `   /   ) /___) /   /                 #
#          _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___               #
#                       Free Content / Management System                 #
#                                   /                                    #
#                                                                        #
#                                                                        #
#   Copyright 2005-2006 by webspell.org                                  #
#                                                                        #
#   visit webSPELL.org, webspell.info to get webSPELL for free           #
#   - Script runs under the GNU GENERAL PUBLIC LICENSE                   #
#   - It's NOT allowed to remove this copyright-tag                      #
#   -- http://www.fsf.org/licensing/licenses/gpl.html                    #
#                                                                        #
#   Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at),   #
#   Far Development by Development Team - webspell.org                   #
#                                                                        #
#   visit webspell.org                                                   #
#                                                                        #
 ########################################################################
*/

if($_GET['id']) {
$id = strip_tags($_GET['id']);

//profil: buddys
if($_GET['action'] == "buddys") {

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

$buddys=safe_query("SELECT buddy FROM ".PREFIX."buddys WHERE userID='$id'");
if(mysql_num_rows($buddys)) {
    $n=1;
	while($db=mysql_fetch_array($buddys)) {
		$n%2 ? $bgcolor=BG_1 : $bgcolor=BG_2;
		$flag = '[flag]'.getcountry($db[buddy]).'[/flag]';
		$country=flags($flag);
		$nicknamebuddy=getnickname($db[buddy]);
		$email="<a href='mailto:".getemail($db[buddy])."'><img src='images/icons/email.gif' border='0'></a>";

  	if(isignored($userID, $db[buddy])) $buddy='<a href="buddys.php?action=readd&id='.$db[buddy].'&userID='.$userID.'"><img src="images/icons/buddy_readd.gif" width="16" height="16" border="0" alt="back to buddy-list"></a>';
		elseif(isbuddy($userID, $db[buddy])) $buddy='<a href="buddys.php?action=ignore&id='.$db[buddy].'&userID='.$userID.'"><img src="images/icons/buddy_ignore.gif" width="16" height="16" border="0" alt="ignore user"></a>';
		elseif($userID==$db[buddy]) $buddy='';
		else $buddy='<a href="buddys.php?action=add&id='.$db[buddy].'&userID='.$userID.'"><img src="images/icons/buddy_add.gif" width="16" height="16" border="0" alt="add to buddylist"></a>';


		if(isonline($db[buddy])=="offline") $statuspic='<img src="images/icons/offline.gif" width="7" height="7" alt="offline">';
		else $statuspic='<img src="images/icons/online.gif" width="7" height="7" alt="online">';

		$buddylist.='<tr bgcolor="'.$bgcolor.'">
                       <td>
					     <table width="100%" cellpadding="0" cellspacing="0">
               <tr>
						     <td>'.$country.' <a href="index.php?site=profile&id='.$db[buddy].'"><b>'.$nicknamebuddy.'</b></a></td>
							 <td align="right">'.$email.'&nbsp;&nbsp;'.$buddy.'&nbsp;&nbsp;'.$statuspic.'</td>
						   </tr>
               </table></td></tr>';
		$n++;
	}
}
else $buddylist='<tr>
                   <td colspan="2" bgcolor="'.BG_1.'">no buddys</td>
                 </tr>';

eval ("\$profile = \"".gettemplate("profile_buddys")."\";");
echo $profile;

//galleries

} elseif($_GET['action'] == "galleries") {

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

$galclass = new Gallery();

$border=BORDER;
$bgcat=BGCAT;

$galleries=safe_query("SELECT * FROM ".PREFIX."gallery WHERE userID='$id'");

echo '<br><table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="'.$border.'">
	<tr><td class="title" colspan="4">&nbsp;&#8226; Galleries of '.getnickname($id).'</tr>
  <tr bgcolor="'.$bgcat.'">
   <td width="100">&nbsp;</td>
   <td width="100"><b>Date</b></td>
   <td><b>Name</b></td>
   <td width="80"><b>Pictures</b></td>
  </tr>';

if($usergalleries) {
 if(mysql_num_rows($galleries)) {
    $n=1;
	while($ds=mysql_fetch_array($galleries)) {
		$n%2 ? $bg=BG_1 : $bg=BG_2;

    $piccount=mysql_num_rows(safe_query("SELECT * FROM ".PREFIX."gallery_pictures WHERE galleryID='".$ds[galleryID]."'"));
    $commentcount=mysql_num_rows(safe_query("SELECT * FROM ".PREFIX."comments WHERE parentID='".$ds[galleryID]."' AND type='ga'"));


		$gallery[date] = date("d.m.Y",$ds[date]);
		$gallery[title] = cleartext($ds[name]);
	  $gallery[picture] = $galclass->randompic($ds[galleryID]);
		$gallery[galleryID] = $ds[galleryID];
		$gallery[count] = mysql_num_rows(safe_query("SELECT picID FROM `".PREFIX."gallery_pictures` WHERE galleryID='".$ds[galleryID]."'"));

    eval ("\$profile = \"".gettemplate("profile_galleries")."\";");
    echo $profile;

		$n++;
	}
 }
 else echo '<tr>
                   <td colspan="4" bgcolor="'.BG_1.'">no galleries</td>
                 </tr>';
} else echo '<tr>
                   <td colspan="4" bgcolor="'.BG_1.'">User-Galleries disabled.</td>
                 </tr>';

echo '</table>';

//profil: last posts

} elseif($_GET['action'] == "lastposts") {

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

if(!isinternboarduser($userID)) $intern = "AND intern='0'";

$topics=safe_query("SELECT * FROM ".PREFIX."forum_topics WHERE userID='".$id."' ".$intern." ORDER BY date DESC LIMIT 0,".$profilelast);
if(mysql_num_rows($topics)) {
    $n=1;
	while($db=mysql_fetch_array($topics)) {
		$n%2 ? $bgcolor=BG_1 : $bgcolor=BG_2;
    $posttime=date("d.m.y h:i",$db[date]);

		$topiclist.='<tr bgcolor="'.$bgcolor.'">
                       <td>
					     <table width="100%" cellpadding="1" cellspacing="1">
               <tr>
						     <td colspan="3"><div style="overflow:hidden;"><a href="index.php?site=forum_topic&topic='.$db[topicID].'">'.$posttime.'<br><b>'.clearfromtags($db[topic]).'</b></a><br><i>'.$db[views].' views - '.$db[replys].' replys</div></td>
						   </tr>
               </table></td></tr>';
		$n++;
	}
}
else $topiclist='<tr>
                   <td colspan="2" bgcolor="'.BG_1.'">no topics</td>
                 </tr>';


$posts=safe_query("SELECT ".PREFIX."forum_topics.topicID, ".PREFIX."forum_topics.topic, ".PREFIX."forum_posts.date, ".PREFIX."forum_posts.message FROM ".PREFIX."forum_posts, ".PREFIX."forum_topics WHERE ".PREFIX."forum_posts.poster='$id' AND ".PREFIX."forum_posts.topicID=".PREFIX."forum_topics.topicID ".$intern." ORDER BY date DESC LIMIT 0,".$profilelast);
if(mysql_num_rows($posts)) {
    $n=1;
	while($db=mysql_fetch_array($posts)) {
		$n%2 ? $bgcolor1=BG_1 : $bgcolor1=BG_2;
		$n%2 ? $bgcolor2=BG_3 : $bgcolor2=BG_4;
    $posttime=date("d.m.y h:i",$db[date]);
    if(strlen($db['message']) > 100) $message=substr($db['message'],0,90+strpos(substr($db['message'],90,strlen($db['message']))," "))."...";
    else $message = $db['message'];

		$postlist.='<tr bgcolor="'.$bgcolor1.'">
                       <td>
					     <table width="100%" cellpadding="1" cellspacing="1">
               <tr>
						     <td colspan="3"><a href="index.php?site=forum_topic&topic='.$db[topicID].'">'.$posttime.' <br><b>'.$db[topic].'</b></a></td>
						   </tr>
						   <tr></tr>
						   <tr>
                <td width="1%">&nbsp;</td>
                <td bgcolor="'.$bgcolor2.'"><div style="overflow:hidden;">'.clearfromtags($message).'</div></td>
                <td width="1%">&nbsp;</td>

               </tr>
               </table></td></tr>';
		$n++;
	}
}
else $postlist='<tr>
                   <td colspan="2" bgcolor="'.BG_1.'">no posts</td>
                 </tr>';



eval ("\$profile = \"".gettemplate("profile_lastposts")."\";");
echo $profile;

//user guestbook

} elseif($_GET['action'] == "guestbook") {

	if($_POST['save']) {
  	include("_mysql.php");
		include("_settings.php");
		include("_functions.php");

		$date = time();
		$ip = getenv(REMOTE_ADDR);
    $run=0;

	if($userID) {
	  $name=getnickname($userID);
		$email=getemail($userID);
		$url=gethomepage($userID);
		$icq=geticq($userID);
		$run=1;
	}
	else {
    $name = $_POST['gbname'];
    $email = $_POST['gbemail'];
    $url = $_POST['gburl'];
    $icq = $_POST['icq'];
		$CAPCLASS = new Captcha;
		if($CAPCLASS->check_captcha($_POST['captcha'], $_POST['captcha_hash'])) $run=1;
	}

	if($run) {

		safe_query("INSERT INTO ".PREFIX."user_gbook (userID, date, name, email, hp, icq, ip, comment)
		                values('$id', '$date', '".mysql_escape_string($_POST['gbname'])."', '".mysql_escape_string($_POST['gbemail'])."', '".mysql_escape_string($_POST['gburl'])."', '".mysql_escape_string($_POST['icq'])."', '$ip', '".mysql_escape_string($_POST['message'])."')");

  	if($id != $userID) sendmessage($id,'New guestbook entry in your profile!','[b]There is a new guestbook entry![/b] [URL=index.php?site=profile&action=guestbook&id='.$id.']Click here[/URL] ');
    }
		redirect("index.php?site=profile&action=guestbook&id=$id",'',0);
	}
	elseif($_GET['delete']) {
  	include("_mysql.php");
		include("_settings.php");
		include("_functions.php");
  	if(!isanyadmin($userID) AND $id != $userID) die('no access!');

		foreach($_POST['gbID'] as $gbook_id) {
    	safe_query("DELETE FROM ".PREFIX."user_gbook WHERE gbID='$gbook_id'");
		}
		redirect("index.php?site=profile&action=guestbook&id=$id",'',0);
	}
	else {
		eval ("\$title_profile = \"".gettemplate("title_profile")."\";");
		echo $title_profile;

		$bg1=BG_1;
		$bg2=BG_2;

		$gesamt = mysql_num_rows(safe_query("SELECT gbID FROM ".PREFIX."user_gbook WHERE userID='".$id."'"));

		$page = $_GET['page'];
		$type = $_GET['type'];

	$pages=1;
	if(!isset($page)) $page = 1;
	if(!isset($type)) $type = "DESC";

	$max=$maxguestbook;

	for ($n=$max; $n<=$gesamt; $n+=$max) {
	    if($gesamt>$n) $pages++;
	}

	if($pages>1) $page_link = makepagelink("index.php?site=profile&id=$id&action=guestbook&type=$type", $page, $pages);

	if ($page == "1") {
	    $ergebnis = safe_query("SELECT * FROM ".PREFIX."user_gbook WHERE userID='$id' ORDER BY date $type LIMIT 0,$max");
		if($type=="DESC") $n=$gesamt;
		else $n=1;
	}
	else {
	    $start=$page*$max-$max;
		$ergebnis = safe_query("SELECT * FROM ".PREFIX."user_gbook WHERE userID='$id' ORDER BY date $type LIMIT $start,$max");
		if($type=="DESC") $n = $gesamt-($page-1)*$max;
		else $n = ($page-1)*$max+1;
	}

    if($type=="ASC")
	    $sorter='<a href="index.php?site=profile&id='.$id.'&action=guestbook&page='.$page.'&type=DESC">Sort:</a> <img src="images/icons/asc.gif" width="9" height="7" border="0">&nbsp;&nbsp;&nbsp;';
	else
	    $sorter='<a href="index.php?site=profile&id='.$id.'&action=guestbook&page='.$page.'&type=ASC">Sort:</a> <img src="images/icons/desc.gif" width="9" height="7" border="0">&nbsp;&nbsp;&nbsp;';

	echo'<table width="100%" cellspacing="0" cellpadding="0">
		  <tr>
		    <td>'.$sorter.' '.$page_link.'</td>
		    <td align="right"><input type="button" onClick="MM_goToURL(\'parent\',\'#addcomment\');return document.MM_returnValue" value="new entry"></td>
		  </tr>
		</table>';

    echo '<form method="post" name="form" action="profile.php?id='.$id.'&action=guestbook&delete=true">';
	while ($ds = mysql_fetch_array($ergebnis)) {
	    $n%2 ? $bg1=BG_1 : $bg1=BG_2;
		$date = date("d.m.Y - H:i", $ds[date]);

		$sem = '^[a-z0-9_\.-]+@[a-z0-9_-]+\.[a-z0-9_\.-]+$';
		if(eregi($sem, $ds[email])) $email = '<a href="mailto:'.$ds[email].'"><img src="images/icons/email.gif" border="0" width="15" height="11" alt="email"></a>';
		else $email='';

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

		$sem = '[0-9]{7,11}';
		$icq_number = str_replace('-','',$ds[icq]);
		if(eregi($sem, $icq_number)) $icq = '<a href="http://www.icq.com/people/about_me.php?uin='.$icq_number.'"><img src="http://online.mirabilis.com/scripts/online.dll?icq='.$icq_number.'&img=5" border="0" alt="icq"></a>';
		else $icq="";

		$name=strip_tags($ds[name]);
		$message=cleartext($ds[comment]);
		$quotemessage=strip_tags($ds[comment]);
		$quotemessage=str_replace("'", "`", $quotemessage);

		$actions='';
		$ip='logged';
		$quote='<a href="javascript:AddCode(\'[quote]'.$name.' wrote: [br]'.$quotemessage.'[/quote]\')"><img src="images/icons/quote.gif" border="0" alt="quote"></a>';
                 if(isfeedbackadmin($userID) || getuserid(getnickname($userID))==$id) {
		    $actions='<input class="input" type="checkbox" name="gbID[]" value="'.$ds[gbID].'">';
			$ip=$ds[ip];
		}

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

		if($type=="DESC") $n--;
		else $n++;
	}

	if(isfeedbackadmin($userID) || getuserid(getnickname($userID))==$id) $submit='<input class="input" type="checkbox" name="ALL" value="ALL" onClick="SelectAll(this.form);"> select all
										  <input type="submit" value="delete selected">';
	echo'<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
  		<td>'.$page_link.'</td>
   		<td align="right">'.$submit.'</td>
		</tr>
		</table></form>';

	echo'<a name="addcomment"></a>';
	if($loggedin) {
	  $name=getnickname($userID);
		$email=getemail($userID);
		$url=gethomepage($userID);
		$icq=geticq($userID);

		eval ("\$profile_guestbook_loggedin = \"".gettemplate("profile_guestbook_loggedin")."\";");
	    echo $profile_guestbook_loggedin;
	}
	else {
		$CAPCLASS = new Captcha;
		$captcha = $CAPCLASS->create_captcha();
		$hash = $CAPCLASS->get_hash();
		$CAPCLASS->clear_oldcaptcha();

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

//profil: home

} else {

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

$date=time();
$ergebnis=safe_query("SELECT * FROM ".PREFIX."user WHERE userID='$id' ");
$anz=mysql_num_rows($ergebnis);
$ds=mysql_fetch_array($ergebnis);

if($userID!=$id && $userID!=0) {
    safe_query("UPDATE ".PREFIX."user SET visits=visits+1 WHERE userID='$id'");
	if(mysql_num_rows(safe_query("SELECT visitID FROM ".PREFIX."user_visitors WHERE userID='$id' AND visitor='$userID' ")))
	    safe_query("UPDATE ".PREFIX."user_visitors SET date='$date' WHERE userID='$id' AND visitor='$userID'");
	else safe_query("INSERT INTO ".PREFIX."user_visitors (userID, visitor, date) values ('$id', '$userID', '$date')");
}
$anzvisits=$ds[visits];
if($ds[userpic]) $userpic='<img src="images/userpics/'.$ds[userpic].'">';
else $userpic='<img src="images/userpics/nouserpic.gif">';
$nickname=$ds[nickname];
if(isclanmember($id)) $member=' <img src="images/icons/member.gif" width="6" height="11" alt="Clanmember">';
else $member='';
$registered=date("d.m.Y - H:i", $ds[registerdate]);
$lastlogin=date("d.m.Y - H:i", $ds[lastlogin]);
if($ds[avatar]) $avatar='<img src="images/avatars/'.$ds[avatar].'">';
else $avatar='<img src="images/avatars/noavatar.gif" border="0">';
$status=isonline($ds[userID]);
$email='<a href="mailto:'.cleartext($ds[email]).'"><img src="images/icons/email.gif" width="15" height="11" border="0" alt="e-mail"></a>';
$sem = '[0-9]{7,11}';
if(eregi($sem, $ds[icq])) $icq = '<a href="http://www.icq.com/people/about_me.php?uin='.sprintf('%d', $ds['icq']).'"><img src="http://online.mirabilis.com/scripts/online.dll?icq='.sprintf('%d', $ds['icq']).'&img=5" border="0" alt="icq"></a>';
else $icq='';
if($loggedin && $ds[userID] != $userID) {
	$pm='<a href="index.php?site=messenger&action=touser&touser='.$ds[userID].'"><img src="images/icons/pm.gif" border="0" width="12" height="13" alt="messenger"></a>';
	if(isignored($userID, $ds[userID])) $buddy='<a href="buddys.php?action=readd&id='.$ds[userID].'&userID='.$userID.'"><img src="images/icons/buddy_readd.gif" width="16" height="16" border="0" alt="back to buddy-list"></a>';
	elseif(isbuddy($userID, $ds[userID])) $buddy='<a href="buddys.php?action=ignore&id='.$ds[userID].'&userID='.$userID.'"><img src="images/icons/buddy_ignore.gif" width="16" height="16" border="0" alt="ignore user"></a>';
	elseif($userID==$ds[userID]) $buddy='';
	else $buddy='<a href="buddys.php?action=add&id='.$ds[userID].'&userID='.$userID.'"><img src="images/icons/buddy_add.gif" width="16" height="16" border="0" alt="add to buddylist"></a>';
}
if($ds[homepage]) {
	if(eregi('http://', $ds[homepage])) $homepage='<a href="'.htmlspecialchars($ds[homepage]).'" target="_blank">'.htmlspecialchars($ds[homepage]).'</a>';
	else $homepage='<a href="http://'.htmlspecialchars($ds[homepage]).'" target="_blank">http://'.htmlspecialchars($ds[homepage]).'</a>';
}
$clanhistory=clearfromtags($ds[clanhistory]);
if($clanhistory=='') $clanhistory="n/a";
$clanname=clearfromtags($ds[clanname]);
if($clanname=='') $clanname="n/a";
$clanirc=clearfromtags($ds[clanirc]);
if($clanirc=='') $clanirc="n/a";
if($ds[clanhp]=='' OR $ds[clanhp]=='n/a') $clanhp = 'n/a';
else {
 if(eregi('http://', $ds[clanhp])) $clanhp='<a href="'.htmlspecialchars($ds[clanhp]).'" target="_blank">'.htmlspecialchars($ds[clanhp]).'</a>';
 else $clanhp='<a href="http://'.htmlspecialchars($ds[clanhp]).'" target="_blank">'.htmlspecialchars($ds[clanhp]).'</a>';
}
$clantag=clearfromtags($ds[clantag]);
if($clantag=='' OR $clantag=='n/a') $clantag="";
else $clantag = $clantag.' / ';

$firstname=clearfromtags($ds[firstname]);
$lastname=clearfromtags($ds[lastname]);

$birthday=substr($ds[birthday],0,10);

$res = mysql_query("SELECT birthday, DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW()) - TO_DAYS(birthday)), '%y') 'age' FROM ".PREFIX."user WHERE userID = '$id'");
$cur = mysql_fetch_array($res);
$birthday=$birthday." (".$cur['age']." years)";


if($ds[sex]=="m") $sex='male';
else $sex='female';
$flag = '[flag]'.$ds[country].'[/flag]';
$profilecountry=flags($flag);
$town=clearfromtags($ds[town]);

$cpu=clearfromtags($ds[cpu]);
$mainboard=clearfromtags($ds[mainboard]);
$ram=clearfromtags($ds[ram]);
$monitor=clearfromtags($ds[monitor]);
$graphiccard=clearfromtags($ds[graphiccard]);
$soundcard=clearfromtags($ds[soundcard]);
$connection=clearfromtags($ds[verbindung]);
$keyboard=clearfromtags($ds[keyboard]);
$mouse=clearfromtags($ds[mouse]);
$mousepad=clearfromtags($ds[mousepad]);


$anznewsposts=getusernewsposts($ds[userID]);
$anzforumtopics=getuserforumtopics($ds[userID]);
$anzforumposts=getuserforumposts($ds[userID]);
$comments[]=getusercomments($ds[userID], 'ne');
$comments[]=getusercomments($ds[userID], 'cw');
$comments[]=getusercomments($ds[userID], 'ar');
$comments[]=getusercomments($ds[userID], 'de');

$pmgot=0;
$pmgot=$ds[pmgot];

$pmsent=0;
$pmsent=$ds[pmsent];

if($ds[about]) $about=cleartext($ds[about]);
else $about="n/a";

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

$visitors=safe_query("SELECT * FROM ".PREFIX."user_visitors WHERE userID='$id' ORDER BY date DESC LIMIT 0,10");
if(mysql_num_rows($visitors)) {
    $n=1;
    while($dv=mysql_fetch_array($visitors)) {
	    $n%2 ? $bgcolor=BG_1 : $bgcolor=BG_2;
		$flag = '[flag]'.getcountry($dv[visitor]).'[/flag]';
		$country=flags($flag);
		$nicknamevisitor=getnickname($dv[visitor]);
		if(isonline($dv[visitor])=="offline") $statuspic='<img src="images/icons/offline.gif" width="7" height="7" alt="offline">';
		else $statuspic='<img src="images/icons/online.gif" width="7" height="7" alt="online">';
		$time=time();
		$visittime=$dv[date];

		$sec=$time-$visittime;
		$days=$sec/86400;								// sekunden / (60*60*24)
		$days=substr($days, 0, strpos($days,"."));		// kommastelle

		$sec=$sec-$days*86400;
		$hours=$sec/3600;
		$hours=substr($hours, 0, strpos($hours,"."));

		$sec=$sec-$hours*3600;
		$minutes=$sec/60;
		$minutes=substr($minutes, 0, strpos($minutes,"."));

		if($time-$visittime<60) {
			$now="now";
			$days="";
			$hours="";
			$minutes="";
		}
		else {
			$now='';
			$days==0 ? $days="" : $days=$days.'d';
			$hours==0 ? $hours="" : $hours=$hours.'h';
			$minutes==0 ? $minutes="" : $minutes=$minutes.'m';
		}

		$lastvisits.='<tr bgcolor="'.$bgcolor.'">
                       <td>
					     <table width="100%" cellpadding="0" cellspacing="0">
					       <tr>
						     <td>'.$country.' <a href="index.php?site=profile&id='.$dv[visitor].'"><b>'.$nicknamevisitor.'</b></a></td>
							 <td align="right" class="small">'.$now.$days.$hours.$minutes.' '.$statuspic.'</td>
						   </tr>
						 </table>
					   </td>
                     </tr>';
		$n++;
	}
}
else $lastvisits='<tr>
                   <td colspan="3" bgcolor="'.BG_1.'">no visits</td>
                 </tr>';



$bg1=BG_1;
$bg2=BG_2;
$bg3=BG_3;
$bg4=BG_4;

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

} else { redirect('index.php?site=news', 'no userid set!'); }
?>