Файл: public_html/page/adm-users.php
Строк: 277
<?php
if (!defined('BASE_DIR')) { exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true)); }
if (!isset($_SESSION['user_id'])) { exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true)); }
if (!$users_info['status']) { exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true)); }
$obEngine->addTitleHtml('Пользователи');
if (isset($_GET['secret']))
{
$_SESSION['admin_user_view'] = $_SESSION['user_id'];
$_SESSION['user_id'] = (int)$_GET['secret'];
exit(header('Location: /'));
}
if (isset($_GET['ban']))
{
$mysqli->query("UPDATE `".PREFIX."_users` SET `ban` = '1' WHERE `id` = '".(int)$_GET['ban']."'");
}
if (isset($_GET['unban']))
{
$mysqli->query("UPDATE `".PREFIX."_users` SET `ban` = '0' WHERE `id` = '".(int)$_GET['unban']."'");
}
?>
<div id="message"><?php echo $msg = isset($_GET['msg']) ? printMessage((int)$_GET['msg']) : ''; ?></div>
<div class="wrapper">
<div class="main">
<div class="m_left">
<?php
if (isset($_GET['edit']))
{
if (isset($_POST['login']))
{
$login = filter_var($_POST['login'], FILTER_SANITIZE_STRING);
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
$wmr = filter_var($_POST['wmr'], FILTER_SANITIZE_STRING);
$payeer = filter_var($_POST['payeer'], FILTER_SANITIZE_STRING);
$money = filter_var($_POST['money'], FILTER_SANITIZE_STRING);
$money_frozen = filter_var($_POST['money_frozen'], FILTER_SANITIZE_STRING);
$mysqli->query("UPDATE `".PREFIX."_users` SET `login` = '".$login."', `email` = '".$email."', `wmr` = '".$wmr."', `payeer` = '".$payeer."', `money` = '".$money."', `money_frozen` = '".$money_frozen."' WHERE `id` = '".(int)$_GET['edit']."'");
exit(header('Location: /adm-users.php?p='.$_GET['p'].'&msg=100'));
}
$query = $mysqli->query("SELECT t1.*, t2.login as referername FROM `".PREFIX."_users` AS t1 LEFT JOIN `".PREFIX."_users` AS t2 ON t1.referer = t2.id WHERE t1.id = '".(int)$_GET['edit']."'");
$res = $query->fetch_assoc();
?>
<div class="m_title"><a href="/adm-users.php?p=<?php echo $page = isset($_GET['p']) ? $_GET['p'] : 1; ?>">Пользователи</a> | Редактирование пользователя №<?php echo (int)$_GET['edit']; ?></div>
<form name="form1" action="" method="post">
<div class="m_l">
<div class="adm_m_name">Логин:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="login" class="tt" value="<?php echo $res['login']; ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">E-mail:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="email" class="tt" value="<?php echo $res['email']; ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">WMR:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="wmr" class="tt" value="<?php echo $res['wmr']; ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Payeer:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="payeer" class="tt" value="<?php echo $res['payeer']; ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Реферер:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="referer" class="tt" disabled="disabled" value="<?php echo $nameref = $res['referername'] ? 'ID: '.$res['referer'].' Логин: '.$res['referername'] : 'нет'; ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Рефералов:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="referals" class="tt" disabled="disabled" value="<?php echo $query = $mysqli->query("SELECT id FROM `".PREFIX."_users` WHERE `referer` = '".$res['id']."'")->num_rows; ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Баланс:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="money" class="tt" value="<?php echo sprintf("%.2f", $res['money']); ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Заработано всего:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="money_all" class="tt" disabled="disabled" value="<?php echo sprintf("%.2f", $res['money_all']); ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Заработано на ссылках:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="money_link" class="tt" disabled="disabled" value="<?php echo sprintf("%.2f", $res['money_link']); ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Заработано на баннерах:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="money_banner" class="tt" disabled="disabled" value="<?php echo sprintf("%.2f", $res['money_banner']); ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Заработано на рефералах:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="money_ref" class="tt" disabled="disabled" value="<?php echo sprintf("%.2f", $res['money_ref']); ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Заморожено:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="money_frozen" class="tt" value="<?php echo sprintf("%.2f", $res['money_frozen']); ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Пополненно:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="money_in" class="tt" disabled="disabled" value="<?php echo sprintf("%.2f", $res['money_in']); ?>"></div>
</div>
<div class="m_l">
<div class="adm_m_name">Выплачено:</div>
<div class="adm_m_pole"><input type="text" maxlength="50" name="money_out" class="tt" disabled="disabled" value="<?php echo sprintf("%.2f", $res['money_out']); ?>"></div>
</div>
<div class="m_l"><button style="float:right;">Сохранить</button></div>
</form>
<?php
}
else if (isset($_GET['refs']))
{
?>
<div class="m_title"><a href="/adm-users.php?p=<?php echo $page = isset($_GET['p']) ? (int)$_GET['p'] : 1; ?>">Пользователи</a> | Рефералы пользователя №<?php echo (int)$_GET['refs']; ?></div>
<?php
$query = $mysqli->query("SELECT `id` FROM `".PREFIX."_users` WHERE `referer` = '".(int)$_GET['refs']."'");
$total = $query->num_rows;
$perpage = 25;
if (empty($_GET['p']) || $_GET['p'] <= 0)
{
$page = 1;
}
else
{
$page = (int)$_GET['p'];
}
$pages_count = ceil($total / $perpage);
if ($page > $pages_count) $page = $pages_count;
$start_pos = ($page - 1) * $perpage;
if ($start_pos < 0) $start_pos = 0;
$query = $mysqli->query("SELECT *, DATE_FORMAT(data_reg, '%d.%m.%y, %H:%i') as f_data_reg FROM `".PREFIX."_users` WHERE `referer` = '".(int)$_GET['refs']."' ORDER BY data_reg DESC LIMIT ".$start_pos.", ".$perpage."");
if ($query->num_rows)
{
?>
<table class="all_table" width="600" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="all_title">ID</td>
<td class="all_title">Логин</td>
<td class="all_title">Дата регистрации</td>
<td class="all_title">Рефералов</td>
<td class="all_title">Баланс</td>
<td class="all_title">Статус/Посл. вход</td>
<td class="all_title">Действия</td>
</tr>
<?php
while ($row = $query->fetch_assoc())
{
$online = TIME - strtotime($row['data_log']) < 180 ? '<b style="color: green;">online</b>' : $row['data_log'];
$ban = $row['ban'] ? 'style="background: red;"' : '';
?>
<tr>
<td <?php echo $ban; ?> class="all_mid"><?php echo $row['id']; ?></td>
<td <?php echo $ban; ?> class="all_mid"><?php echo $row['login']; ?></td>
<td <?php echo $ban; ?> class="all_mid"><?php echo $row['f_data_reg']; ?></td>
<?php
$count_ref = $mysqli->query("SELECT id FROM `".PREFIX."_users` WHERE `referer` = '".$row['id']."'")->num_rows;
?>
<td <?php echo $ban; ?> class="all_mid"><?php echo $count_ref = $count_ref ? '<a href="adm-users.php?refs='.$row['id'].'&p='.$page.'">'.$count_ref.'</a>' : '0'; ?></td>
<td <?php echo $ban; ?> class="all_mid"><b><?php echo sprintf("%.2f", $row['money']); ?></b> руб.</td>
<td <?php echo $ban; ?> class="all_mid"><?php echo $online; ?></td>
<td <?php echo $ban; ?> class="all_mid">
<span class="list-group-item"><i class="fa fa-button fa-user-secret fa-fw" href="/adm-users.php?secret=<?php echo $row['id']; ?>" title="Шпионить за пользователем" onclick="location = $(this).attr('href');"></i></span>
<span class="list-group-item"><i class="fa fa-pencil-square fa-button fa-fw" title="Редактировать пользователя" href="/adm-users.php?edit=<?php echo $row['id']; ?>&p=<?php echo $page; ?>" onclick="location = $(this).attr('href');"></i></span>
<?php
if ($row['ban'])
{
?>
<span class="list-group-item"><i class="fa fa-unlock fa-button fa-fw" title="Разбанить пользователя" href="/adm-users.php?unban=<?php echo $row['id']; ?>&p=<?php echo $page; ?>" onclick="location = $(this).attr('href');"></i></span>
<?php
}
else
{
?>
<span class="list-group-item"><i class="fa fa-lock fa-button fa-fw" title="Забанить пользователя" href="/adm-users.php?ban=<?php echo $row['id']; ?>&p=<?php echo $page; ?>" onclick="location = $(this).attr('href');"></i></span>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
if ($total > $perpage)
{
printPageNav($page, $pages_count, 'adm-users.php', $total, $perpage);
}
}
}
else
{
$query = $mysqli->query("SELECT `id` FROM `".PREFIX."_users`");
$total = $query->num_rows;
$perpage = 25;
if (empty($_GET['p']) || $_GET['p'] <= 0)
{
$page = 1;
}
else
{
$page = (int)$_GET['p'];
}
$pages_count = ceil($total / $perpage);
if ($page > $pages_count) $page = $pages_count;
$start_pos = ($page - 1) * $perpage;
if ($start_pos < 0) $start_pos = 0;
$query = $mysqli->query("SELECT *, DATE_FORMAT(data_reg, '%d.%m.%y, %H:%i') as f_data_reg FROM `".PREFIX."_users` LIMIT ".$start_pos.", ".$perpage."");
if ($query->num_rows)
{
?>
<div class="m_title">Пользователи</div>
<table class="all_table" width="600" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="all_title">ID</td>
<td class="all_title">Логин</td>
<td class="all_title">Дата регистрации</td>
<td class="all_title">Рефералов</td>
<td class="all_title">Баланс</td>
<td class="all_title">Статус/Посл. вход</td>
<td class="all_title">Действия</td>
</tr>
<?php
while ($row = $query->fetch_assoc())
{
$online = TIME - strtotime($row['data_log']) < 300 ? '<b style="color: green;">online</b>' : $row['data_log'];
$ban = $row['ban'] ? 'style="background-color: red;"' : '';
?>
<tr>
<td <?php echo $ban; ?> class="all_mid"><?php echo $row['id']; ?></td>
<td <?php echo $ban; ?> class="all_mid"><?php echo $row['login']; ?></td>
<td <?php echo $ban; ?> class="all_mid"><?php echo $row['f_data_reg']; ?></td>
<?php
$count_ref = $mysqli->query("SELECT id FROM `".PREFIX."_users` WHERE `referer` = '".$row['id']."'")->num_rows;
?>
<td <?php echo $ban; ?> class="all_mid"><?php echo $count_ref = $count_ref ? '<a href="adm-users.php?refs='.$row['id'].'&p='.$page.'">'.$count_ref.'</a>' : '0'; ?></td>
<td <?php echo $ban; ?> class="all_mid"><b><?php echo sprintf("%.2f", $row['money']); ?></b> руб.</td>
<td <?php echo $ban; ?> class="all_mid"><?php echo $online; ?></td>
<td <?php echo $ban; ?> class="all_mid">
<span class="list-group-item"><i class="fa fa-button fa-user-secret fa-fw" href="/adm-users.php?secret=<?php echo $row['id']; ?>" title="Шпионить за пользователем" onclick="location = $(this).attr('href');"></i></span>
<span class="list-group-item"><i class="fa fa-pencil-square fa-button fa-fw" title="Редактировать пользователя" href="/adm-users.php?edit=<?php echo $row['id']; ?>&p=<?php echo $page; ?>" onclick="location = $(this).attr('href');"></i></span>
<?php
if ($row['ban'])
{
?>
<span class="list-group-item"><i class="fa fa-unlock fa-button fa-fw" title="Разбанить пользователя" href="/adm-users.php?unban=<?php echo $row['id']; ?>&p=<?php echo $page; ?>" onclick="location = $(this).attr('href');"></i></span>
<?php
}
else
{
?>
<span class="list-group-item"><i class="fa fa-lock fa-button fa-fw" title="Забанить пользователя" href="/adm-users.php?ban=<?php echo $row['id']; ?>&p=<?php echo $page; ?>" onclick="location = $(this).attr('href');"></i></span>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
if ($total > $perpage)
{
printPageNav($page, $pages_count, 'adm-users.php', $total, $perpage);
}
}
}
?>
</div>
<?php include 'module/user_menu.php'; ?>
</div>
</div>