View file modules/2ads/plugins/go.php

File size: 1.7Kb
<?php

if (post('ok')){
  
  $day = abs(intval(post('day')));
  $sum = $day * abs(intval(config('ADS2_SUM')));
  $time = $day * 86400;
  
  if (user('MONEY') < $sum){
    
    error('Недостаточно денег на счету');
    redirect('/m/2ads/?go='.$ads['ID']);
    
  }
  
  $atime = db::get_column("SELECT `ATIME` FROM `ADS2` WHERE `ID` = ? LIMIT 1", [$ads['ID']]);
  
  db::get_set("UPDATE `USERS` SET `MONEY` = ? WHERE `ID` = ? LIMIT 1", [(user('MONEY') - $sum), user('ID')]);
  db::get_set("UPDATE `ADS2` SET `ATIME` = ? WHERE `ID` = ? LIMIT 1", [($atime > TM ? ($atime + $time) : (TM + $time)), $ads['ID']]);
  
  success('Срок показа успешно продлен');
  redirect('/m/2ads/?go='.$ads['ID']);
  
}

?>
<div class='list-body'>
  
<div class='list-menu'><center>
<?=lg('Площадка')?> <b><?=tabs($ads['NAME'])?></b>
</center></div>

<div class='list-menu'>
<?=lg('Стоимость 1 дня рекламы')?>: <b><?=money(abs(intval(config('ADS2_SUM'))), 3)?></b><br />
<?=lg('Баланс аккаунта')?>: <b><?=money(user('MONEY'), 3)?></b><br />
<?=lg('Текущий срок до')?>: <b><?=($ads['ATIME'] > TM ? ftime($ads['ATIME']) : lg('не активен'))?></b>
</div>

</div>

<div class='list'>
<form method='post' class='ajax-form' action='/m/2ads/?go=<?=$ads['ID']?>'>
<?=html::input('day', 'Введите кол-во дней', null, null, null, 'form-control-100', 'number', null, 'clock-o')?>
<?=html::button('button ajax-button', 'ok', 'plus', 'Продлить')?><br /><br />
<small><?=lg('Рекламные ссылки показываются рандомно внизу страниц сайта')?></small>
</form>
</div>
<?

back('/m/2ads/');
acms_footer();