Файл: inc/bonus.php
Строк: 68
<?php
/* Бонус */
if (isset($active)) {
$stmt_rec = $connect->prepare("select count(*) from `bonus_rec` where `bid` = ?");
$stmt_user_rec = $connect->prepare("select count(*) from `bonus_rec` where `bid` = ? and `uid` = ?");
$sql = $connect->query("select * from `bonus` where (`date` = '0' or `date` = curdate()) and `start` < curtime() and `end` > curtime()")->fetchAll();
foreach ($sql as $row) {
$stmt_rec->execute(array($row['id']));
$count_rec = $stmt_rec->fetchColumn();
if ($row['limit'] == 0 || $row['limit'] > $count_rec) {
$stmt_user_rec->execute(array($row['id'], $user['id']));
$user_rec = $stmt_user_rec->fetchColumn();
if (!$user_rec) {
if (isset($_POST['bonus_rec']) &&
!empty($_POST['code']) && isset($_SESSION['code']) &&
$_SESSION['code'] == $_POST['code']) {
$sum = f_rand($row['min'], $row['max']);
$stmt = $connect->prepare("insert into `bonus_rec` set `time` = ?, `bid` = ?, `uid` = ?, `sum` = ?");
if (pay($sum, $user['id']) && $stmt->execute(array(time(), $row['id'], $user['id'], $sum))) {
notification('Вы получили бонус в размере '.rub($sum), $user['id']);
header('Location: '.$_SERVER['REQUEST_URI']);
}
}
echo '<div id="bonus" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content wa-smile-menu">
<center>
<form action="" method="POST">
<div class="vote">
Бонус: <span class="green">'.($row['min'] == $row['max'] ? $row['min'] : $row['min'].' - '.$row['max']).'</span><br/>
<div class="red">Бонус действует до '.$row['end'].'</div>
<input type="text" id="inp_code" name="code" size="5">
<img id="captcha" src="/img/code.php" alt="check" onClick="UpCaptcha()"><br/>
<input type="submit" name="bonus_rec" value="Забрать бонус">
<input type="button" name="cancel" data-dismiss="modal" value="Закрыть">
'.($row['comment'] ? '<br/><div class="chi">'.$row['comment'].'</div>' : '').'
</div>
</form></center>
</div></div></div>';
?>
<script>
$(function() {
$('#bonus').on('shown.bs.modal', function () {
$('#inp_code').focus();
});
$('#bonus').modal('show');
});
</script>
<?
break;
}
}
}
}