Вход Регистрация
Файл: pages/admin/moi_akzii.php
Строк: 76
<?php
// Physical module map v50.6.
if (!defined('GAME_ROOT')) define('GAME_ROOT'dirname(__DIR__2));
chdir(GAME_ROOT);
if (
PHP_SAPI !== 'cli') { $_SERVER['PHP_SELF']='/moi_akzii.php'$_SERVER['SCRIPT_NAME']='/moi_akzii.php'; }
require_once 
'./system/common.php'; require_once './system/functions.php'; require_once './system/user.php';
if(!
$user || (int)($user['access']??0)<2){ header('Location: /'); exit; }
$labels=[1=>'Тренировка',2=>'Арена',3=>'Руны',4=>'Вещи',5=>'Бонус вещи',7=>'Акция Золото ×2'];
if((
$_SERVER['REQUEST_METHOD']??'GET')==='POST'){
    
security_require_csrf();
    
$id=(int)($_POST['skidka_u']??0); $discount=max(0,min(100,(int)($_POST['skidka']??0))); $days=max(0,min(365,(int)($_POST['time']??0)));
    if(!isset(
$labels[$id]) || $days<1$_SESSION['err']='Некорректные параметры акции.';
    else{ 
$defs=game_promo_defaults()['skilka']; $until=time()+$days*86400$def=$defs[$id]??['name'=>$labels[$id],'url'=>'']; db_execute('INSERT INTO `skilka` (`id`,`zena`,`nazvanie`,`url`,`time`) VALUES (:id,:z,:n,:u,:t) ON DUPLICATE KEY UPDATE `zena`=:z2,`nazvanie`=:n2,`url`=:u2,`time`=:t2',['id'=>$id,'z'=>$discount,'n'=>$def['name'],'u'=>$def['url'],'t'=>$until,'z2'=>$discount,'n2'=>$def['name'],'u2'=>$def['url'],'t2'=>$until]); $_SESSION['ok']='Акция включена и будет отображаться игрокам.'; }
    
header('Location: /moi_akzii/'); exit;
}
$title='Акции'; require './system/h.php';
?>
<div class="block_light center"><b>Управление акциями</b></div>
<div class="block_zero center"><form method="post" action="/moi_akzii/"><?=security_csrf_field()?>
<select name="skidka_u"><?php foreach($labels as $id=>$label): ?><option value="<?=$id?>"><?=security_html($label)?></option><?php endforeach; ?></select><br>
Скидка, %:<br><input type="number" name="skidka" min="0" max="100" required><br>
Срок акции, дней:<br><input name="time" type="number" min="1" max="365" required><br>
<button class="btn" type="submit">Изменить</button></form></div>
<div class="block_light center"><b>Сейчас активно</b></div><?php foreach(game_active_promos(20) as $promo): if($promo['kind']!=='skilka') continue; ?><div class="block_zero"><a href="<?=security_html($promo['url'])?>"><?=security_html($promo['name'])?></a><?php if((int)$promo['discount']>0): ?> — <span class="green"><?=(int)$promo['discount']?>%</span><?php endif; ?><br><small>до <span data-live-until="<?=(int)$promo['until']?>" data-live-format="short"><?=_time(max(0,(int)$promo['until']-time()))?></span></small></div><?php endforeach; ?>
<?php 
require './system/f.php'?>
Онлайн: 2
Реклама