<?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                                                   #
#                                                                        #
 ########################################################################
*/

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


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

function clear($text) {
    $text=strip_tags($text);
	$text=str_replace ("javascript:", "", $text);
	$text=stripslashes($text);
	
	return $text;
}

$alle = safe_query("SELECT userID FROM ".PREFIX."user");
$gesamt = mysql_num_rows($alle);
$pages=1;
if(!isset($page)) $page = 1;
if(!isset($sort)) $sort="nickname";
if(!isset($type)) $type = "ASC";
		
$max=$maxusers;
				
for ($n=$max; $n<=$gesamt; $n+=$max) {
    if($gesamt>$n) $pages++;
}
		 	
if($pages>1) $page_link = makepagelink("index.php?site=registered_users&sort=$sort&type=$type", $page, $pages);
	
if ($page == "1") {
    $ergebnis = safe_query("SELECT * FROM ".PREFIX."user ORDER BY $sort $type LIMIT 0,$max");
	if($type=="DESC") $n=$gesamt;
	else $n=1;
}
else {
    $start=$page*$max-$max;
    $ergebnis = safe_query("SELECT * FROM ".PREFIX."user ORDER BY $sort $type LIMIT $start,$max");
	if($type=="DESC") $n = ($gesamt)-$page*$max+$max;
	else $n = ($gesamt+1)-$page*$max+$max;
}
	
$anz=mysql_num_rows($ergebnis);
if($anz) {
    echo'<table width="100%" cellpadding="2" cellspacing="0">
	       <tr>
		     <td>';
	
	if($type=="ASC") 
		    echo'<a href="index.php?site=registered_users&page='.$page.'&sort='.$sort.'&type=DESC">Sort:</a> <img src="images/icons/asc.gif" width="9" height="7" border="0">&nbsp;&nbsp;&nbsp;';
		else 
		    echo'<a href="index.php?site=registered_users&page='.$page.'&sort='.$sort.'&type=ASC">Sort:</a> <img src="images/icons/desc.gif" width="9" height="7" border="0">&nbsp;&nbsp;&nbsp;';
	
	echo $page_link.'</td><td align="right"><b>'.$gesamt.'</b> registered users</td>
		   </tr>
		 </table><br>';
		 
	eval ("\$registered_users_head = \"".gettemplate("registered_users_head")."\";");
    echo $registered_users_head;	
	$n=1;
	while($ds=mysql_fetch_array($ergebnis)) {
	    if($n%2) {
			$bg1=BG_1;
			$bg2=BG_2;
		}
		else {
			$bg1=BG_3;
			$bg2=BG_4;
		}
		$id=$ds[userID];
		$country='[flag]'.getcountry($ds[userID]).'[/flag]';
		$country=flags($country);
		$nickname='<a href="index.php?site=profile&id='.$ds[userID].'"><b>'.getnickname($ds[userID]).'</b></a>';
		if(isclanmember($ds[userID])) $member=' <img src="images/icons/member.gif" width="6" height="11" alt="Clanmember">';
		else $member='';
		$email='<a href="mailto:'.getemail($ds[userID]).'"><img src="images/icons/email.gif" border="0" width="15" height="11" alt="e-mail"></a>';
		
		$sem = '^[http://]+[a-z0-9_\.-]+[a-z0-9_-]+$';
	    if(!(eregi($sem, $ds[homepage]))) $homepage='';
		else $homepage='<a href="'.gethomepage($ds[userID]).'" target="_blank"><img src="images/icons/hp.gif" border="0" width="14" height="14" alt="homepage"></a>';
		
		$pm='';
		$buddy='';
		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>';
		}
		$lastlogindate=date("d.m.Y", $ds[lastlogin]);
		$lastlogintime=date("H:i", $ds[lastlogin]);
		$registereddate=date("d.m.Y", $ds[registerdate]);
		$status=isonline($ds[userID]);
		
		if($status=="offline") $login=$lastlogindate.' - '.$lastlogintime;
		else $login='<img src="images/icons/online.gif" width="7" height="7" alt="online"> now online';
		
		eval ("\$registered_users_content = \"".gettemplate("registered_users_content")."\";");
        echo $registered_users_content;
		$n++;
	}
	eval ("\$registered_users_foot = \"".gettemplate("registered_users_foot")."\";");
    echo $registered_users_foot;

}
else echo'no users';
?>
