Файл: vk/admin/users.php
Строк: 96
<?php
if($_GET['action'] == "delete" && isset($_GET['uid'])){
$q = $db->mysql_qw("SELECT * FROM users WHERE uid = ?;",$_GET['uid']);
if(mysql_num_rows($q)>0){
if(isset($_POST['delete'])){
$db->mysql_qw("DELETE FROM users WHERE uid = ?;",$_GET['uid']);
echo "
<div class='alert alert-success'>
<b>Пользователь успешно удален!</b>
</div>
";
}else{
echo "
<center>
<b>Вы действительно хотите удалить Пользователя?</b>
<form method='post'>
<input type='hidden' name='delete' value='1'>
<input type='submit' class='btn btn-info' value='Удалить'>
<input type='button' class='btn btn-danger' value='Отменить' onClick='window.location.href="?page=notes&gpage=".$_GET['gpage']."";'>
</form>
</center>
";
}
}else{
echo "
<div class='alert alert-error'>
<b>Запись с данным ID не найдена!</b>
</div>
";
}
exit();
}
if($_GET['action'] == "edit" && isset($_GET['uid'])){
if(isset($_POST['first_name'])){
foreach($_POST as $key=>$val){
$string .= ",".$key."='".$val."'";
}
$string = substr($string, 1);
mysql_query("UPDATE users SET ".$string." WHERE uid = ".$_GET['uid'].";");
echo "
<div class='alert alert-success'>
<b>Пользователь отредактирован!</b>
</div>
";
}
$q = $db->mysql_qw("SELECT * FROM users WHERE uid = ?;",$_GET['uid']);
if(mysql_num_rows($q)>0){
while($val = mysql_fetch_assoc($q)){
echo "
<form method='post'>
<table class='admint'>
<tr>
<td>Имя</td>
<td><input type='text' name='first_name' value='".$val['first_name']."'></td>
</tr>
<tr>
<td>Фамилия</td>
<td><input type='text' name='last_name' value='".$val['last_name']."'></td>
</tr>
<tr>
<td>Баллов</td>
<td><input type='text' name='bals' value='".$val['bals']."'></td>
</tr>
<tr>
<td>Пригласил</td>
<td><input type='text' name='ref' value='".$val['ref']."'></td>
</tr>
<tr>
<td>Заработал Рефер</td>
<td><input type='text' name='ref_earn' value='".$val['ref_earn']."'></td>
</tr>
<tr>
<td>Списал Рефер</td>
<td><input type='text' name='ref_withdraw' value='".$val['ref_withdraw']."'></td>
</tr>
<tr>
<td>Дата регистрации</td>
<td><input type='text' name='reg_date' value='".$val['reg_date']."'></td>
</tr>
</table>
<br>
<input type='submit' class='btn btn-info' value='Сохранить'> <input type='button' class='btn btn-danger' value='Отменить' onClick='window.location.href="?page=notes&gpage=".$_GET['gpage']."";'>
</form>
";
}
}else{
echo "
<div class='alert alert-error'>
<b>Запись с данным ID не найдена!</b>
</div>
";
}
}else{
$q = $db->mysql_qw("SELECT * FROM users;");
$on_page = 10;
$pages = ceil(mysql_num_rows($q) / $on_page);
if($pages == 0){
echo "<center><h3>Не зарегистрировано ни одного пользователя</h3></center>";
}else{
if(!isset($_GET['gpage'])){
$page_now = 1;
}else{
$page_now = $_GET['gpage'];
}
echo "Выберите страницу: ";
for($c=1;$c<=$pages;$c++){
if($c == $page_now){
echo "<b>".$c."</b> ";
}else{
echo "<a href='?page=users&gpage=".$c."'>".$c."</a> ";
}
}
$sd = $page_now * $on_page - $on_page;
echo "
<table class='admint'>
<tr>
<td>Имя</td>
<td>Фамилия</td>
<td>Баллов</td>
<td>Пригласил</td>
<td>Заработал Рефер</td>
<td>Списал Рефер</td>
<td>Дата регистрации</td>
<td>Приг. чел.</td>
<td></td>
</tr>
";
$q = $db->mysql_qw("SELECT u1.*,COUNT(u2.ref) AS refs FROM users u1 LEFT OUTER JOIN users u2 ON u1.uid = u2.ref GROUP BY u1.uid LIMIT ?,?",$sd, $on_page);
while($val = mysql_fetch_assoc($q)){
$date = date("H:i d.m.Y",$val['created']);
echo "
<tr>
<td>".$val['first_name']."</td>
<td>".$val['last_name']."</td>
<td>".$val['bals']."</td>
<td>".$val['ref']."</td>
<td>".$val['ref_earn']."</td>
<td>".$val['ref_withdraw']."</td>
<td>".$val['reg_date']."</td>
<td>".$val['refs']."</td>
<td>
<a href='?page=users&gpage=".$page_now."&uid=".$val['uid']."&action=edit'><img src='http://cdn2.iconfinder.com/data/icons/diagona/icon/16/018.png' class='editt'></a>
<a href='?page=users&gpage=".$page_now."&uid=".$val['uid']."&action=delete'><img src='http://cdn2.iconfinder.com/data/icons/diagona/icon/16/101.png' class='deletet'></a>
</td>
</tr>
";
}
echo "</table>";
}
}
?>