<?php if(!defined('FastCore')){exit('Oops!');}
$opt['title'] = 'Редактирование ссылки';
# Параметры серфинга
$configSurf = $db->query("SELECT * FROM `db_surf_config` WHERE id = 1")->fetchArray();
$timerr = $configSurf['timer'];
$timer = array($timerr,$timerr*2,$timerr*3,$timerr*4,$timerr*5,$timerr*6);
?>
<!-- Header -->
<div class="header pb-6">
</div>
<!-- Page content -->
<div class="container-fluid">
<div class="row">
<?PHP
if(isset($_POST['surf_id'])) {
$surf_id = filter_var($_POST['surf_id'],FILTER_VALIDATE_INT);
if($surf_id === FALSE){
Header('Location: /user/surf/links'); return;
}
$db->query("SELECT * FROM `db_surf` WHERE `id` = '$surf_id'");
if($db->numRows() == 0){
Header('Location: /user/surf/links'); return;
}
$result = $db->fetchArray();
if($result['uid'] != $uid && $uid != 1){
Header('Location: /user/surf/links'); return;
}
$title = $result['title'];
$url = $result['url'];
?>
<div class="col-sm-12">
<script>
function PlanChange(frm)
{
lprice = bux_price;
if (frm.vip.value == 1) {
lprice += bux_price_move;
}
if (frm.wind.value == 1) {
lprice += bux_price_high;
}
if (frm.timer.value == 10) {
lprice += bux_price_timer;
} else
if (frm.timer.value == 20) {
lprice += (bux_price_timer * 2);
} else
if (frm.timer.value == 30) {
lprice += (bux_price_timer * 3);
} else
if (frm.timer.value == 40) {
lprice += (bux_price_timer * 4);
} else
if (frm.timer.value == 50) {
lprice += (bux_price_timer * 5);
} else
if (frm.timer.value == 60) {
lprice += (bux_price_timer * 6);
}
frm.linkprice.value = number_format(lprice, 6, '.', '');
}
function number_format(number, decimals, dec_point, thousands_sep) {
var i, j, kw, kd, km;
if (isNaN(decimals = Math.abs(decimals))) {
decimals = 2;
}
if (dec_point == undefined) {
dec_point = ",";
}
if (thousands_sep == undefined) {
thousands_sep = ".";
}
i = parseInt(number = (+number || 0).toFixed(decimals)) + "";
if ((j = i.length) > 3) {
j = j % 3;
} else {
j = 0;
}
km = (j ? i.substr(0, j) + thousands_sep : "");
kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
return km + kw + kd;
}
var bux_price = <?=$configSurf['price_click']; ?>;
var bux_price_high = <?=$configSurf['wind']; ?>;
var bux_price_timer = <?=$configSurf['timer_pay']; ?>;
var bux_price_move = <?=$configSurf['vip']; ?>;
function ClearForm()
{
document.forms['surforder'].timer.value = <?=$configSurf['timer']; ?>;
document.forms['surforder'].vip.value = 0;
document.forms['surforder'].wind.value = 0;
PlanChange(document.forms['surforder']);
}
$(document).ready(function() { ClearForm(); });
</script>
<div class="card shadow-sm">
<div class="card-header text-uppercase p-3">
<div class="row align-items-center">
<div class="col">
<h3 class="mb-0">Редактирование площадки ID: <?=$surf_id;?></h3>
</div>
<div class="col text-right">
<a href="/user/surf/links" class="btn btn-primary">Мои ссылки</a>
</div>
</div>
</div>
</div>
<br>
<div class="card shadow-sm">
<div class="card-body pb-2">
<form name="surforder" action="" class="mb-0" method="POST" id="surf_edit" onsubmit="return SbmForm(); return false;">
<?php $func->csrf(); ?>
<div class="input-group mb-2">
<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-edit"></i></span></div>
<input class="form-control" type="text" name="title" id="title" value="<?=$title;?>" placeholder="Придумайте название ссылки" required>
</div>
<div class="input-group mb-2">
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-link"></i></span></div>
<input class="form-control" type="text" name="url" id="url" value="<?=$url;?>" placeholder="Адрес ссылки пример: https://example.com" required>
</div>
<div class="input-group mb-2" title="Продолжительность просмотра ссылки">
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-clock"></i></span></div>
<select class="form-control" name="timer" id="timer" onChange="PlanChange(this.form); return false;" required style="
height: calc(40px + 2px);
">
<?php
foreach ($timer as $surf) {
$priceTimer += $configSurf['timer_pay']; // цена таймера
?>
<option value="<?=$surf;?>">Таймер: <?=$surf;?> секунд (+ <?=$priceTimer;?> ₽ )</option>
<? } ?>
</select>
</div>
<div class="row">
<div class="col-md-4"><label class="mb-1">Активное окно</label>
<div class="input-group mb-2" title="Активное окно (Просмотр ссылки в активном окне).">
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-desktop"></i></span></div>
<select class="form-control" name="wind" id="wind" onChange="PlanChange(this.form); return false;" required style="height: calc(50px + 2px);">
<option value="0">Нет</option>
<option value="1">Да (+ <?=$configSurf['wind']; ?>₽ )</option>
</select>
</div>
</div>
<div class="col-md-4"><label class="mb-1">Выделить ссылку</label>
<div class="input-group mb-2" title="Выделить ссылку в списке">
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-star"></i></span></div>
<select class="form-control" name="vip" id="vip" onChange="PlanChange(this.form); return false;" required style="height: calc(50px + 2px);">
<option value="0">Нет</option>
<option value="1">Да (+ <?=$configSurf['vip']; ?> ₽ )</option>
</select>
</div>
</div>
<div class="col-md-4"><label class="mb-1">Период повтора</label>
<div class="input-group mb-2" title="Период повтора через который пользователю вновь будет доступна ссылка">
<div class="input-group-prepend"><span class="input-group-text"><i class="fa fa-reply"></i></span></div>
<select class="form-control" name="reply" id="reply" required style="height: calc(50px + 2px);">
<option value="0">Каждые 24 часа</option>
<option value="1">Каждые 12 часов</option>
</select>
</div>
</div>
</div>
<div class="row align-items-center">
<div class="col">
<input type="hidden" id="type" name="type" value="edit">
<input type="hidden" id="edit" name="edit" value="edit">
<input type="hidden" name="surf_id" value="<?=$surf_id;?>">
<input type="hidden" id="request" name="request" value="/ajax.php?action=surf&type=edit">
<button type="submit" class="btn btn-primary btn-fw">сохранить</button>
</div>
<div class="col-sm-4 col-md-3 float-right">
<label class="mb-1"><small>Цена 1 перехода:</small></label>
<div class="input-group input-group-sm float-right">
<div class="input-group-prepend"><span class="input-group-text">₽</span></div>
<input class="form-control col text-primary" name="linkprice" value="<?=$configSurf['price_click']+$configSurf['timer_pay']; ?>" readonly="readonly" style="font-size: 20px;font-weight:600;">
</div>
</div>
</div>
</form><br/>
</div></div>
</div>
<?php
} else {
Header('Location: /user/surf/links'); return;
}
?>
</div></div>
</div>