<?
if (!defined('webid')) {
    exit();
}

if ($user_status != 'admin') {
    exit();
}
if (isset($_POST['ban'])) {
    mysql_query("UPDATE tb_users SET ban = 1  WHERE id = '" . intval($_POST['id']) . "'");
}
?>
<style type="text/css">
.cons {
    width: 400px;
    background: #fafafa;
    margin-bottom: 20px;
    padding: 10px;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    -khtml-border-radius: 3px;
    border-radius: 3px;
    -moz-box-shadow: 0 0 2px rgba(0,0,0,0.2);
	-webkit-box-shadow: 0 0 2px rgba(0,0,0,0.2);
    -khtml-box-shadow: 0 0 2px rgba(0,0,0,0.2);
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
    
}
</style>
<div class="cons">
<form action="" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="400" style="padding: 5px;"><select name="namev" style="width: 99%;"><option value="ban">Заблокированы</option><option value="finestatus">Оштрафованы</option></select></td>
<td style="padding: 5px;"><input type="submit" name="search" value="Поиск" id="save" /></td>
</tr>
</table>
</form>
</div>
<table width="45%" border="0" cellpadding="0" cellspacing="1" class="tab">
<thead style="background: #ebebeb;">
    <th width="30" align="center">ID</th>
    <th width="100" align="center">Пользователь</th>
    <th width="100" align="center">IP</th>
    <th width="100">Кошелек</th>
    <th width="100">Баланс рабочий</th>
    <th width="100">Баланс рекламный</th>
    <th width="100">Выплаты</th>
    <th width="100">Заработано</th>
    
</thead>
<?
$zapros = 'ip';
if (isset($_POST['search'])) {
    $zapros = $_POST['namev'];
}
$sql = mysql_fetch_array(mysql_query("select ip, pemail, wmid, count($zapros) as dubcount from tb_users group by $zapros having dubcount > 1 and $zapros != ''"));
if ($_POST['namev'] == 'ban' and $sql[ip] != '') {
    $sql2 = mysql_query("SELECT * FROM tb_users WHERE ban=1 ORDER by IP ASC");
} else
if ($_POST['namev'] == 'finestatus') {
    $sql2 = mysql_query("SELECT * FROM tb_users WHERE finestatus=1 ORDER by pemail ASC");
}
while ($row2 = mysql_fetch_array($sql2)) {
    if ($row2['ban'] == 1 AND $row2['finestatus'] == 0) {
        $col = 'style="background:#F6EBEB;color: #800000;"';
    } else 
	if ($row2['finestatus'] == 1 AND $row2['ban'] == 0){
        $col = 'style="background:#F0F8FF;color: #4682B4;"';
    } else 
	if ($row2['finestatus'] == 1 AND $row2['ban'] == 1){
        $col = 'style="background:#FFFFE0;color: #B8860B;"';
    }
    ?>
    <tr>
        <td class="rt" <?=$col?>><?=$row2['id']?></td>
        <td class="rt" <?=$col?>><?=$row2['username']?></td>
        <td class="rt" <?=$col?>><?=$row2['ip']?></td>
        <td class="rt" <?=$col?>><?=$row2['pemail']?></td>
        <td class="rt" <?=$col?>><?=$row2['money']?></td>
        <td class="rt" <?=$col?>><?=$row2['admoney']?></td>
        <td class="rt" <?=$col?>><?=$row2['paid']?></td>
        <td class="rt" <?=$col?>><?=$row2['money']+$row2['paid']?></td>
        
    </tr>
    <?
}
?>
</table>