<?php
define('NTLCMS', 1);
$module = 'panel';
include ('../system/start.php');
include ('../system/function.php');
include ('../system/antidos.php');
include ('../system/head.php');
if ($active && $_USER['admin'] == '1'){
echo '<div class="title"><b>'.razd.' Админ-Панель | Доп.настройки</b></div>';
if (!isset($_POST['ok'])){
echo '<form action="'.URL.'/_set" method="post" name="form">';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Минималка '.money().'руб.:<br/>';
echo '<input type="text" name="mincost" maxlength="4" value="'.((int) $set['mincost']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> К пополнению [%]:<br/>';
echo '<input type="text" name="inpay" maxlength="3" value="'.((int) $set['inpay']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Комиссия:<br/>';
echo '<input type="text" name="commission" maxlength="3" value="'.((int) $set['commission']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Рефералка [%]:<br/>';
echo '<input type="text" name="refpercent" maxlength="4" value="'.((int) $set['refpercent']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Бонус за клик:<br/>';
echo '<input type="text" name="cost" maxlength="6" value="'.((float) $set['cost']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Бонус за регу:<br/>';
echo '<input type="text" name="payreg" maxlength="6" value="'.((int) $set['payreg']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Бонус за пост:<br/>';
echo '<input type="text" name="paychat" maxlength="6" value="'.((float) $set['paychat']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Бонус за отзыв:<br/>';
echo '<input type="text" name="payrev" maxlength="6" value="'.((float) $set['payrev']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Проклик ссылки:<br/>';
echo '<input type="text" name="timeclick" maxlength="4" value="'.((int) $set['timeclick']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Максимум сайтов:<br/>';
echo '<input type="text" name="maxsite" maxlength="3" value="'.((int) $set['maxsite']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Моментальная продажа '.coins().' кр:<br/>';
echo '<input type="text" name="sale" maxlength="5" value="'.((float) $set['sale']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Мин '.coins().' кр в продаже:<br/>';
echo '<input type="text" name="csale" maxlength="4" value="'.((int) $set['csale']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Моментальная покупка '.coins().' кр:<br/>';
echo '<input type="text" name="purchase" maxlength="3" value="'.((int) $set['purchase']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Мин '.coins().' кр в покупке:<br/>';
echo '<input type="text" name="cpurchase" maxlength="4" value="'.((int) $set['cpurchase']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Мин '.coins().' кр в активе:<br/>';
echo '<input type="text" name="mactive" maxlength="4" value="'.((int) $set['mactive']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Стоимость рассылки:<br/>';
echo '<input type="text" name="costspam" maxlength="4" value="'.((int) $set['costspam']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Цена реклама '.money().'руб:<br/>';
echo '<input type="text" name="rekcost" maxlength="5" value="'.((float) $set['rekcost']).'"/></div>';
echo '<div class="menu"><i class="fa fa-dot-circle-o fa-fw"></i> Мин кликов для комментариев:<br/>';
echo '<input type="text" name="min_clicks_comment" maxlength="5" value="'.((int) $set['min_clicks_comment']).'"/></div>';
echo '<div class="menu"><input name="ok" type="submit" value="Сохранить настройки"/></form></div>';
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/_control">Админ-Панель</a></div>';
} else {	
$error = null;
if (isset($_POST['mincost'])){
$mincost = isset($_POST['mincost']) ? filter_var($_POST['mincost'], FILTER_SANITIZE_NUMBER_INT) : '0';
$refpercent = isset($_POST['refpercent']) ? filter_var($_POST['refpercent'], FILTER_SANITIZE_NUMBER_INT) : '0';
$timeclick = isset($_POST['timeclick']) ? filter_var($_POST['timeclick'], FILTER_SANITIZE_NUMBER_INT) : '0';
$maxsite = isset($_POST['maxsite']) ? filter_var($_POST['maxsite'], FILTER_SANITIZE_NUMBER_INT) : '0';
$cost = isset($_POST['cost']) ? filter_var($_POST['cost'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : '0.000';
$commission = isset($_POST['commission']) ? filter_var($_POST['commission'], FILTER_SANITIZE_NUMBER_INT) : '0';
$inpay = isset($_POST['inpay']) ? filter_var($_POST['inpay'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : '0.00';
$payreg = isset($_POST['payreg']) ? filter_var($_POST['payreg'], FILTER_SANITIZE_NUMBER_INT) : '0';
$paychat = isset($_POST['paychat']) ? filter_var($_POST['paychat'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : '0.00';
$payrev = isset($_POST['payrev']) ? filter_var($_POST['payrev'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : '0.00';	
$sale = isset($_POST['sale']) ? filter_var($_POST['sale'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : '0.00';	
$csale = isset($_POST['csale']) ? filter_var($_POST['csale'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : '0';	
$purchase = isset($_POST['purchase']) ? filter_var($_POST['purchase'], FILTER_SANITIZE_NUMBER_INT) : '0';	
$cpurchase = isset($_POST['cpurchase']) ? filter_var($_POST['cpurchase'], FILTER_SANITIZE_NUMBER_INT) : '0';	
$mactive = isset($_POST['mactive']) ? filter_var($_POST['mactive'], FILTER_SANITIZE_NUMBER_INT) : '0';	
$costspam = isset($_POST['costspam']) ? filter_var($_POST['costspam'], FILTER_SANITIZE_NUMBER_INT) : '0';	
$privcost = isset($_POST['privcost']) ? filter_var($_POST['privcost'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : '0.00';	
$privsale = isset($_POST['privsale']) ? filter_var($_POST['privsale'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : '0.00';	
$rekcost = isset($_POST['rekcost']) ? filter_var($_POST['rekcost'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : '0.00';
$min_clicks_comment = isset($_POST['min_clicks_comment']) ? filter_var($_POST['min_clicks_comment'], FILTER_SANITIZE_NUMBER_INT) : '100';

if (empty($mincost)){
$error .= 'Поле <b>Min на вывод</b> не должно быть пустым!<br/>';
}
if ($error){
echo '<div class="post"><center><i class="fa fa-close fa-fw"></i> '.$error.'</center></div>';
} else {
DB :: run() -> query("update `set` set `value` = '".$mincost."' where `name` = 'mincost'");
DB :: run() -> query("update `set` set `value` = '".$refpercent."' where `name` = 'refpercent'");
DB :: run() -> query("update `set` set `value` = '".$timeclick."' where `name` = 'timeclick'");
DB :: run() -> query("update `set` set `value` = '".$maxsite."' where `name` = 'maxsite'");
DB :: run() -> query("update `set` set `value` = '".$cost."' where `name` = 'cost'");
DB :: run() -> query("update `set` set `value` = '".$commission."' where `name` = 'commission'");
DB :: run() -> query("update `set` set `value` = '".$inpay."' where `name` = 'inpay'");
DB :: run() -> query("update `set` set `value` = '".$payreg."' where `name` = 'payreg'");
DB :: run() -> query("update `set` set `value` = '".$paychat."' where `name` = 'paychat'");
DB :: run() -> query("update `set` set `value` = '".$payrev."' where `name` = 'payrev'");
DB :: run() -> query("update `set` set `value` = '".$sale."' where `name` = 'sale'");
DB :: run() -> query("update `set` set `value` = '".$csale."' where `name` = 'csale'");
DB :: run() -> query("update `set` set `value` = '".$purchase."' where `name` = 'purchase'");
DB :: run() -> query("update `set` set `value` = '".$cpurchase."' where `name` = 'cpurchase'");
DB :: run() -> query("update `set` set `value` = '".$mactive."' where `name` = 'mactive'");
DB :: run() -> query("update `set` set `value` = '".$costspam."' where `name` = 'costspam'");
DB :: run() -> query("update `set` set `value` = '".$privcost."' where `name` = 'privcost'");
DB :: run() -> query("update `set` set `value` = '".$privsale."' where `name` = 'privsale'");
DB :: run() -> query("update `set` set `value` = '".$rekcost."' where `name` = 'rekcost'");
DB :: run() -> query("update `set` set `value` = '".$min_clicks_comment."' where `name` = 'min_clicks_comment'");
$_SESSION['success'] = 'Настройки успешно изменены!';
header('Location: '.URL.'/_set');
}	
}
echo '<div class="block"><i class="fa fa-home fa-fw"></i> <a href="'.URL.'/cabinet">В кабинет</a> | <a href="'.URL.'/_control">Админ-Панель</a></div>';
}
} else {
echo '<div class="title"><b>'.razd.' Проверка прав доступа</b></div>';
echo '<div class="menu"><center><i class="fa fa-close fa-fw"></i> Доступ запрещен!</center></div>';
echo '<div class="block"><i class="fa fa-home fa-fw"></i> '.(isset($active) ? '<a href="'.URL.'/cabinet">В кабинет</a>' : '<a href="'.URL.'">На главную</a>').'</div>';
}
include ('../system/foot.php');
?>