battles/fancy/type_rating.php

63 lines
2.8 KiB
PHP

<?
include('../config.php');
function show_nick($user) {
$r = '';
if($user['align'] != 0) {
$r .= '<img src=\'i/align_'.$user['align'].'.gif\' /> ';
}
if($user['klan'] != '') {
$r .= '<img src=\'/i/klan/'.ClanImage($user['klan']).'.gif\' /> ';
}
$r .= '<b>'.$user['login'].'</b> ['.$user['level'].'] <a href=\'inf.php?'.$user['id'].'\' target=\'_blank\'><img src=\'i/inf.gif\' /></a>';
return $r;
}
function ClanImage($clan_id) {
$clanimg = mysql_fetch_assoc(mysql_query("SELECT `short` FROM `clans` WHERE `id` = '{$clan_id}' LIMIT 1"));
if($clanimg['short']) {
$clanimg = $clanimg['short'];
} else {
$clanimg = "1x1";
}
return $clanimg;
}
function form($type) {
$i = 1; $r = ''; $rs = '';
$tps = array('exp' => 'Опыта', 'win' => 'Побед', 'lose' => 'Поражений', 'nich' => 'Ничьих');
$r .= '<table width="100%" border="0" cellpadding="0" cellspacing="0" background="static/images/rating/ram12_34.gif"><tbody><tr><td align="left" scope="col"><img src="static/images/rating/ram12_33.gif" width="12" height="11"></td><td scope="col"></td><td width="18" align="right" scope="col"><img src="static/images/rating/ram12_35.gif" width="13" height="11"></td></tr></tbody></table>';
$r .= '<table width="100%" border="0" align="center"> <tbody><tr> <td width="25">&nbsp;</td> <td align="center"><b>Персонаж</b></td> <td align="center"><b>'.$tps[$type].'</b></td> </tr> ';
$data = mysql_query('SELECT `id`, `login`, `level`, `align`, `klan`, `exp`, `win`, `lose`, `nich`, `bot`, `block` FROM `users` WHERE `bot` = 0 AND `align` != 2.99 AND `block` = 0 AND `email` != "admin@old-dark.ru" ORDER BY `'.$type.'` DESC LIMIT 100');
while($row = mysql_fetch_array($data)) {
if($type == 'exp') { $rs = $row['exp']; }
if($type == 'win') { $rs = $row['win']; }
if($type == 'lose') { $rs = $row['lose']; }
if($type == 'nich') { $rs = $row['nich']; }
$r .= '<tr>';
$r .= '<td align="center"><b>'.$i.'</b></td>';
$r .= '<td>'.show_nick($row).'</td>';
$r .= '<td align="center"><b>'.$rs.'</b></td>';
$r .= '</tr>';
$i++;
}
$r .= '</table>';
$r .= '<table width="100%" border="0" cellpadding="0" cellspacing="0" background="static/images/rating/ram12_34.gif"><tbody><tr><td align="left" scope="col"><img src="static/images/rating/ram12_33.gif" width="12" height="11"></td><td scope="col"></td><td width="18" align="right" scope="col"><img src="static/images/rating/ram12_35.gif" width="13" height="11"></td></tr></tbody></table>';
return $r;
}
if($_POST['type']) {
if($_POST['type'] == 'exp') {
echo form('exp');
} elseif($_POST['type'] == 'win') {
echo form('win');
} elseif($_POST['type'] == 'lose') {
echo form('lose');
} elseif($_POST['type'] == 'nich') {
echo form('nich');
} else {
echo 'Потерян параметр сортировки ...';
}
}
?>