<?
include_once("req.php");
array_walk($_REQUEST,"format_string");   
array_walk($_POST,"format_string");   
array_walk($_GET,"format_string"); 
 include_once('database.php');
if ($_REQUEST['clan']) {
	$clanname=$_REQUEST['clan'];
	echo "<SCRIPT>
function w(login,id,align,klan,level,boss,rank,online,block, city){
	var s=\"\";
	if (online!=0) {
		if (city!=\"\") {
			s='<IMG SRC=../i/lock.gif WIDTH=20 HEIGHT=15 ALT=\"Онлайн\">';
		} else {
			s='<IMG SRC=../i/lock.gif WIDTH=20 HEIGHT=15 ALT=\"Онлайн\">';
		}
	} else { s='<IMG SRC=\"../i/offline.gif\" WIDTH=20 HEIGHT=15 BORDER=0 ALT=\"Нет в клубе\">'; }
	if (city!=\"\") {
		s+='<img src=\"../i/misc/forum/fo'+city+'.gif\" width=17 height=15>';
	}

	s+=' <IMG SRC=../i/align'+align+'.gif WIDTH=12 HEIGHT=15>';
	if (klan!='') {s+='<A HREF=\"/encicl/klan/'+klan+'.html\" target=_blank><IMG SRC=\"../i/klan/'+klan+'.gif\" WIDTH=24 HEIGHT=15 ALT=\"\"></A>'}
	s+='';
	if (online!=0) {s+=login} else {s+='<FONT color=gray><b>'+login+'</b>'}
	s+='['+level+']<a href=http://antibk.org/inf.php?'+id+' target=_blank><IMG SRC=../i/inf.gif WIDTH=12 HEIGHT=11 ALT=\"Информация о персонаже\"></a>';
	if (block != '' && block != '0') {s+=' &nbsp; - <font color=red><b>заблокирован</b></font>'}
	else {
		if (boss != '' && boss != '0') { s+=' &nbsp; - <font color=336666><b>глава клана</b></font>' }
		else { if (rank != '') {s+=' &nbsp; - '+rank} }
	}
	if (online==0) {s+='</FONT>'};

	document.write(s+'<BR>');
}
</SCRIPT>";

$sostav=$sostav."<TABLE cellspacing=0 cellpadding=2><TR><TD align=center>
	<h4>Клан ".$clanname."</TD></TR><TR><TD nowrap><SCRIPT>";
	$res=db_use('query',"select p.persname,u.login,p.id_person,p.level,p.id_city,s.session_id,p.clanzvan,p.blocked,p.align,cp.rightsmask,a.fullname 
	from person p 
	left join clans c on c.id_clan=p.id_clan
	left join users u on p.id_person=u.id_person
	left join clans_pers cp on p.id_person=cp.id_person 
	left join align a on a.align=p.align
	left join sessions s on s.username=u.login where c.clanname='".$clanname."' 
	order by align desc,COALESCE(p.persname,u.login)");
unset ($i);while ($i<mysql_num_rows($res)) { # получить массив противников
	$i++;$s=mysql_fetch_array($res);
	$name=($s['persname']?$s['persname']:$s['login']);
	$glava=$s['rightsmask'][0];
	$sostav=$sostav."w('".$name."',".$s['id_person'].",'".$s['align']."','".$clanname."',".$s['level'].",'".$glava."','<b>".str_replace("'","\'",$s['clanzvan'])."</b>',".($s['session_id']?'1':'0').",'".($s['block'])."','".$s['id_city']."');";
	
	}
$sostav=$sostav."</SCRIPT></TD></TR><TR><TD>Всего: <B>".$i."</B><BR>
	<small>(список обновляется <strike>в полночь</strike> каждый раз)</small>
	</TD></TR></TABLE>";
echo $sostav;


	#	$res=db_use('query',"select * from drwfl where clanname='".$clanname."';");

}else{die('Не передано название клана');}

?>
<?
?>