<?php
admin :: access(array('a'=>3));
$id = (isset($_GET['id']) ? intval($_GET['id']) : 0 );
$d = profile :: getUser($id);
$bl = false;
$errorP = NULL;
if(isset($_POST['cancel'])) {
system :: redirect(NULL, $thisLink."/?act=user/block&id={$d['id']}");
} else if(isset($_POST['cfms'])) {
$timeb = intval($_POST['time']);
$cause = intval($_POST['cause']);
if(in_array($timeb, array(0,1,3,12,24,48,120))) {
if($cause >= 0 && $cause <= 5) {
if($cause == 0 && $timeb != 0) {
$errorP = "Предупреждение можно выдавать только без времени.";
} else {
$bl = true;
$timest = time() + $timeb * 60 * 60; // Time block in timest. .
if(isset($_POST['access']) && $_POST['access'] == ACCESS) {
$block_db = DB :: $pdo -> querySingle("SELECT COUNT(*) FROM `blocks` WHERE `id_user` = ? AND `id_data` = ? AND `cause` <> ? AND `unlock` = ? LIMIT 1;", array($d['id'], $user['id'], 0, 0));
if($block_db == 0) {
DB :: $pdo -> query("INSERT INTO `blocks` (`id_user`, `id_data`, `time`, `date`, `cause`) VALUES (?, ?, ?, ?, ?);", array($d['id'], $user['id'], time(), $timest, $cause));
DB :: $pdo -> query("UPDATE `users` SET `block_time` = ?, `count_blocks` = `count_blocks`+1, `block_unlock` = '0',`block_cause` = ? WHERE `id` = ? LIMIT 1;", array($timest, $cause, $d['id']));
system :: redirect("Пользователь успешно заблокирован.", profile :: getLink($d));
} else {
$errorP = "Пользователь уже заблокирован.";
}
}
}
} else { $errorP = "Не верно указана причина блокировки."; }
} else { $errorP = "Не верно указано время блокировки."; }
}
$title = $l = "Панель управления - Блокировка пользователя";
require (CORE."head.php");
system :: show($errorP);
echo "<div class=\"app-block\">";
echo system :: touch(profile :: getLink($d),"
<div class=\"post-l emotion-show\" data-emotions=\"".system::textOut($d['emotions'])."\">
".profile :: userAvatar($d,0)."
</div>
<div class=\"post-c\">
<div class=\"_name\">".profile :: getName($d, true)."</div>
<div class=\"_gray\">Время на сайте: ".profile :: onlineTime($d['online_time'])."</div>
<div class=\"_gray\">Дата регистрации: ".system :: times($d['first_time'])."</div>
<div class=\"_gray\">Блокировок: ".$d['count_blocks']."</div>
</div>
");
?>
<div>
<form method="post" action="">
<?php if(isset($_POST['cfms']) && $bl == true) {?>
<div class="list">
<div><span class="_gray">Время:</span> <?=$timeb." час".profile :: getPhrase($timeb,array('','а','ов'))?></div>
<div><span class="_gray">Блокировка до:</span> <?=system :: times($timest)?></div>
<div><span class="_gray">Причина:</span> <?=$config['CAUSE_BLOCK'][$cause]?></div>
<input type="hidden" name="time" value="<?=$timeb?>" />
<input type="hidden" name="cause" value="<?=$cause?>" />
<input type="hidden" name="access" value="<?=ACCESS?>" />
</div>
<div class="list">
<div class="_dib _oh"><input type="submit" name="cfms" class="main-btn" value="Да, заблокировать" /></div>
<div class="_dib _oh"><input type="submit" name="cancel" class="action-btn" value="Отменить" /></div>
</div>
<?php } else { ?>
<div class="list">
<div class="_gray">Время:</div>
<select class="_dbl _w-100" name="time">
<option name="time" value="0">0 часов</option>
<option name="time" value="1">1 час</option>
<option name="time" value="3">3 часа</option>
<option name="time" value="12">12 часов</option>
<option name="time" value="24">24 часа</option>
<option name="time" value="48">48 часов</option>
<option name="time" value="120">120 часов</option>
</select>
</div>
<div class="list">
<div class="_gray">Причина:</div>
<div><label class="_gray _dbl">
<input name="cause" type="radio" value="0" checked="checked" /> <?=$config['CAUSE_BLOCK'][0]?>
</label></div>
<div><label class="_gray _dbl">
<input name="cause" type="radio" value="1" /> <?=$config['CAUSE_BLOCK'][1]?>
</label></div>
<div><label class="_gray _dbl">
<input name="cause" type="radio" value="2" /> <?=$config['CAUSE_BLOCK'][2]?>
</label></div>
<div><label class="_gray _dbl">
<input name="cause" type="radio" value="3" /> <?=$config['CAUSE_BLOCK'][3]?>
</label></div>
<div><label class="_gray _dbl">
<input name="cause" type="radio" value="4" /> <?=$config['CAUSE_BLOCK'][4]?>
</label></div>
<div><label class="_gray _dbl">
<input name="cause" type="radio" value="5" /> <?=$config['CAUSE_BLOCK'][5]?>
</label></div>
</div>
<div class="list">
<input type="submit" name="cfms" class="main-btn _dbl _w-100" value="Заблокировать" />
</div>
<?php } ?>
</form>
</div>
<?php
echo system :: back("/admin/?act=user/info&id={$d['id']}","Информация", true);
echo "</div>";
require (CORE."foot.php");