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

if ($user_status != 'admin') {
    exit();
}

if (isset($_POST['reas'])) {
    mysql_query("UPDATE tb_advban SET reas = '".check_text(substr($_POST['reas'], 0, 35))."', modered = 2 WHERE id = '".intval($_POST['id'])."'");
}
if (isset($_POST['ok'])) {
    mysql_query("UPDATE tb_advban SET reas = '', modered = 1 WHERE id = '".intval($_POST['id'])."'") or die(error());
}
?>
<script type="text/javascript">
function hideserfaddblock(bname) {
    if (document.getElementById(bname).style.display == 'none') {
        document.getElementById(bname).style.display = '';
    } else {
        document.getElementById(bname).style.display = 'none';
    }
    return false;
}
</script>
<table width="60%" border="0" cellpadding="0" cellspacing="1" class="tab">
    <thead style="background: #ebebeb;" class="rt">
        <th style="padding: 5px;" width="20" align="center">ID</th>
        <th>URL</th>
        <th style="padding: 5px;" width="20" align="center">Цена</th>
        <th style="padding: 5px;" width="45" align="center">User ID</th>
        <th colspan="2" align="center" width="60">Действия</th>
    </thead>
<?
$sql = mysql_query("SELECT id, url, price, fromus FROM tb_advban WHERE modered = 0");
while ($row = mysql_fetch_array($sql)) {
    ?>
    <tr>
        <td class="rt" align="center"><?=$row['id']?></td>
        <td class="rt"><a href="<?=$row['url']?>" target="_blank"><?=$row['url']?></a></td>
        <td class="rt" align="center"><?=$row['price']?></td>
        <td class="rt" align="center"><?=$row['fromus']?></td>
        <td class="rt" align="center" width="30"><form action="" method="post"><input type="hidden" name="ok" /><input type="hidden" name="id" value="<?=$row['id']?>" /><input type="submit" id="save" value="Одобрить" /></form></td>
        <td class="rt" align="center" width="30"><a href="#" onclick="hideserfaddblock('open<?=$row['id']?>'); return false;" id="save">Отклонить</a></td>
    </tr>
    <tr id="open<?=$row['id']?>" style="display: none;"><td colspan="8" class="rt" align="right" style="background: #ebebeb;"><form action="" method="post">Причина: <input type="text" name="reas" size="50" /><input type="hidden" name="id" value="<?=$row['id']?>" />&nbsp;&nbsp;<input type="submit" value="Отправить" id="save" /></form></td></tr>
    <?
}
?>
</table>