$lnk=$sort$qsex$qpow$qpag$qppp&bio=1>Show bio";
if($bio) $clmn="$tccellh>User bio $smallfont($lnk=$sort$qsex$qpow$qpag$qppp>hide)";
if($sort=='rating') $clmn="$tccellh colspan=3>User rating";
if($sex=='m') $where='WHERE sex=0';
if($sex=='f') $where='WHERE sex=1';
if($sex=='n') $where='WHERE sex=2';
if($pow!=''){
if($where) $where.=" AND powerlevel=$pow";
else $where="WHERE powerlevel=$pow";
}
$query='SELECT id,posts,regdate,name,picture,bio,powerlevel,sex,r.* FROM users LEFT JOIN users_rpg r ON id=uid ';
if($sort=='posts' or $sort=='') $users1=mysql_query("$query$where ORDER BY posts DESC");
if($sort=='name') $users1=mysql_query("$query$where ORDER BY name");
if($sort=='reg') $users1=mysql_query("$query$where ORDER BY regdate DESC");
if($sort=='exp' or $sort=='rating') $users1=mysql_query("$query$where");
if($sort=='age'){
if($sex=='m') $where='AND sex=0';
if($sex=='f') $where='AND sex=1';
if($sex=='n') $where='AND sex=2';
$where.=($where?' AND birthday':'WHERE birthday');
$users1=mysql_query("$query $where ORDER BY birthday") or print mysql_error();
}
$numusers=mysql_num_rows($users1);
for($i=0;$user=mysql_fetch_array($users1);$i++){
$user[days]=(ctime()-$user[regdate])/86400;
$user[exp]=calcexp($user[posts],$user[days]);
$user[lvl]=calclvl($user[exp]);
$users[$user[id]]=$user;
$rate[$i][0]=$user[id];
$rate[$i][2]=$user[exp];
}
if($sort=='rating'){
mysql_data_seek($users1,0);
for($i=0;$user=mysql_fetch_array($users1);$i++){
$ratescore=0;
$ratetotal=0;
$ratings=mysql_query("SELECT userfrom,userrated,rating FROM userratings WHERE userrated=$user[id]");
while($rating=@mysql_fetch_array($ratings)){
$l=$users[$rating[userfrom]][lvl];
if($l<1) $l=1;
$ratescore+=$rating[rating]*$l;
$ratetotal+=10*$l;
}
$numvotes=@mysql_num_rows($ratings);
$s=($numvotes>1?'s':'');
if($numvotes){
$rate[$i][0]=$user[id];
$rate[$i][1]=$ratescore*100000/$ratetotal;
$users[$user[id]][5]='
'.(sprintf('%01.2f',$rate[$i][1]/10000))."$tccell2>$ratescore / $ratetotal$tccell2>$numvotes vote$s";
$rate[$i][1]=$rate[$i][1]/10+10000;
}else{
$numusers--;
$i--;
}
}
usort($rate,'sortbyrating');
}
if($sort=='exp') usort($rate,'sortbyexp');
$pagelinks=$smallfont.'Pages:';
for($i=0;$i<($numusers/$ppp);$i++){
$pagelinks.=($i==$page?' '.($i+1):" ".($i+1).'');
}
if($numusers>1) $s="s";
print "
$header
$tblstart
$tccellh colspan=2>$numusers user$s found.
$tccell1s> Sort by:
$tccell2s>
$lnk=posts$q$qpow$qsex>Total posts |
$lnk=exp$q$qpow$qsex>EXP |
$lnk=name$q$qpow$qsex>User name |
$lnk=reg$q$qpow$qsex>Registration date |
$lnk=age$q$qpow$qsex>Age |
$lnk=rating$q$qpow$qsex>Rating
$tccell1s> Sex:
$tccell2s>
$lnk=$sort$q$qpow&sex=m>Male |
$lnk=$sort$q$qpow&sex=f>Female |
$lnk=$sort$q$qpow&sex=n>N/A |
$lnk=$sort$q$qpow>All
$tccell1s> Powerlevel:
$tccell2s>
$lnk=$sort$q$qsex&pow=-1>Banned |
$lnk=$sort$q$qsex&pow=0>Normal |
$lnk=$sort$q$qsex&pow=1>Local moderator |
$lnk=$sort$q$qsex&pow=2>Full moderator |
$lnk=$sort$q$qsex&pow=3>Administrator |
$lnk=$sort$q$qsex>All
$tblend
$tblstart
$tccellh width=30>#
$tccellh width=60>Picture
$tccellh>Username
";
if(!$rpg){
print "
$clmn
$tccellh width=150>Registered on
$tccellh width=60>Posts
$tccellh width=30>Level
$tccellh width=100>EXP
";
}else{
print "$tccellh width=30>Level";
for($i=0;$i<9;$i++) print "$tccellh width=6%>".$stat[$i].'';
print "$tccellh width=9%>
";
}
$i=$ppp*$page;
for($u=0;$rate[$i] && $i<($ppp*($page+1)) && $i<$numusers;$u++){
if($u) $ulist.='
';
$user=$users[$rate[$i][0]];
$t=$user[0];
$user[picture]=str_replace('>','%3E',$user[picture]);
$userpicture="";
if(!$user[picture]) $userpicture=' ';
$namecolor=getnamecolor($user[sex],$user[powerlevel]);
if(!$bio and $sort!='rating') $user[5]=' ';
if($rpg){
$eqitems=mysql_query("SELECT * FROM items");
while($item=mysql_fetch_array($eqitems)) $items[$item[id]]=$item;
$stats=getstats($user,$items);
}
$ulist.="
$tccell2>".($i+1).".
$tccell1l>$userpicture
$tccell2l>$user[3]
";
if(!$rpg){
$ulist.="
$tccell1ls>$user[5]
$tccell2>".date($dateformat,$user[2]+$tzoff)."
$tccell1>$user[1]
$tccell1>$user[lvl]
$tccell1>$user[exp]
";
}else{
$ulist.="$tccell1>$user[lvl]";
for($k=0;$k<9;$k++) $ulist.="$tccell1>".$stats[$stat[$k]].'';
$ulist.="$tccell1>$stats[GP]";
}
$i++;
}
print "$ulist$tblend$pagelinks$footer";
printtimedif($startingtime);
?>