<?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(!$userID) echo 'You have to be logged in to view your profile!<br><br>

			  &#8226; <a href="index.php?site=register">register now</a><br>
			  &#8226; <a href="index.php?site=login">log in</a>';
			  
else {

	if($_GET['action']=="add") {
	  include("_mysql.php");
		include("_settings.php");
	  include("_functions.php");
	  if(!$userID) die('Not logged in.');
	
		safe_query("INSERT INTO ".PREFIX."buddys (userID, buddy, banned) values ('$userID', '".$_GET['id']."', '0') ");
		header("Location: index.php?site=buddys");
	}
	elseif($_GET['action']=="ignore") {
	  include("_mysql.php");
		include("_settings.php");
	  include("_functions.php");
	  if(!$userID) die('Not logged in.');
	
		safe_query("UPDATE ".PREFIX."buddys SET banned='1' WHERE userID='$userID' AND buddy='".$_GET['id']."'");
		header("Location: index.php?site=buddys");
	}
	elseif($_GET['action']=="readd") {
	  include("_mysql.php");
		include("_settings.php");
	  include("_functions.php");
	  if(!$userID) die('Not logged in.');
	
		safe_query("UPDATE ".PREFIX."buddys SET banned='0' WHERE userID='$userID' AND buddy='".$_GET['id']."'");
		header("Location: index.php?site=buddys");
	}
	elseif($_GET['action']=="delete") {
	  include("_mysql.php");
		include("_settings.php");
	  include("_functions.php");
	  if(!$userID) die('Not logged in.');
	
		safe_query("DELETE FROM ".PREFIX."buddys WHERE userID='$userID' AND buddy='".$_GET['id']."'");
		header("Location: index.php?site=buddys");
	}
	else {
		eval ("\$title_buddys = \"".gettemplate("title_buddys")."\";");
		echo $title_buddys;
	
	    echo'<table width="100%" cellpadding="0" cellspacing="0">
		       <tr><td width="49%" valign="top">';
		
		eval ("\$buddys_head = \"".gettemplate("buddys_head")."\";");
		echo $buddys_head;
		$ergebnis=safe_query("SELECT * FROM ".PREFIX."buddys WHERE userID='$userID' AND banned='0'");
		$anz=mysql_num_rows($ergebnis);
		if($anz) {
		    $n=1;
			while($ds=mysql_fetch_array($ergebnis)) {
				if($n%2) {
					$bg1=BG_1;
					$bg2=BG_2;
				}
				else {
					$bg1=BG_3;
					$bg2=BG_4;
				}
				$flag = '[flag]'.getcountry($ds[buddy]).'[/flag]';
				$country=flags($flag);
				$nickname=getnickname($ds[buddy]);
				if(isclanmember($ds[buddy])) $member=' <img src="images/icons/member.gif" width="6" height="11" alt="Clanmember">';
				else $member='';
				if(isonline($ds[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">';
				
				eval ("\$buddys_content = \"".gettemplate("buddys_content")."\";");
				echo $buddys_content;  
				$n++;  
			}
		}
		else echo'<tr><td colspan="4" bgcolor="'.BG_1.'">no users on your buddy-list.</td></tr>';
		eval ("\$buddys_foot = \"".gettemplate("buddys_foot")."\";");
		echo $buddys_foot;
		
		echo'</td><td width="2%">&nbsp;</td><td valign="top">';
		
		eval ("\$ignore_head = \"".gettemplate("ignore_head")."\";");
		echo $ignore_head;
		$ergebnis=safe_query("SELECT * FROM ".PREFIX."buddys WHERE userID='$userID' AND banned='1'");
		$anz=mysql_num_rows($ergebnis);
		if($anz) {
			$n=1;
			while($ds=mysql_fetch_array($ergebnis)) {
				if($n%2) {
					$bg1=BG_1;
					$bg2=BG_2;
				}
				else {
					$bg1=BG_3;
					$bg2=BG_4;
				}
				$flag = '[flag]'.getcountry($ds[buddy]).'[/flag]';
				$country=flags($flag);
				$nickname=getnickname($ds[buddy]);
				if(isclanmember($ds[buddy])) $member=' <img src="images/icons/member.gif" width="6" height="11" alt="Clanmember">';
				else $member='';
				if(isonline($ds[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">';
				eval ("\$ignore_content = \"".gettemplate("ignore_content")."\";");
				echo $ignore_content; 
				$n++;   
			}
		}
		else echo'<tr><td colspan="4" bgcolor="'.BG_1.'">no users on your ignore-list.</td></tr>';
		eval ("\$ignore_foot = \"".gettemplate("ignore_foot")."\";");
		echo $ignore_foot;
		
		echo'</td></tr></table><br>';
	}
}
?>
