Файл: panel/rekl.php
Строк: 249
<?php
/* DCMS Special
* Дата последнего редактирования 14.12.2015
* Модифицировал densnet
*/
foreach (array('start', 'compress', 'sess', 'settings', 'db_connect', 'ipua', 'fnc', 'adm_check', 'user') as $inc) {
require_once "../sys/inc/{$inc}.php";
}
access('adm_rekl', null, 'index.php?' . SID);
adm_check();
if (isset($_GET['sel']) && is_numeric($_GET['sel']) && $_GET['sel'] > 0 && $_GET['sel'] <= 4) {
$sel = intval($_GET['sel']);
$set['title'] = 'Реклама';
require_once H . 'sys/inc/thead.php';
aut();
err();
#Навигация
echo "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/panel/'>Панель управления</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/panel/rekl.php'>Реклама и баннеры</a></li>";
echo "</ul>";
echo "</nav>";
if (isset($_GET['add']) && isset($_POST['name']) && $_POST['name'] != NULL && isset($_POST['link']) && isset($_POST['img']) && isset($_POST['ch']) && isset($_POST['mn'])) {
$ch = intval($_POST['ch']);
$mn = intval($_POST['mn']);
$time_last = time() + $ch * $mn * 60 * 60 * 24;
if (isset($_POST['dop_str']) && $_POST['dop_str'] == 1) {
$dop_str = 1;
} else {
$dop_str = 0;
}
$link = stripcslashes(htmlspecialchars($_POST['link']));
$name = stripcslashes(htmlspecialchars($_POST['name']));
$img = stripcslashes(htmlspecialchars($_POST['img']));
mysql_query("INSERT INTO `rekl` (`time_last`, `name`, `img`, `link`, `sel`, `dop_str`) VALUES ('$time_last', '$name', '$img', '$link', '$sel', '$dop_str')");
msg('Рекламная ссылка добавлена');
} elseif (isset($_GET['set']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `rekl` WHERE `sel` = '$sel' AND `id` = '" . intval($_GET['set']) . "'"), 0) && isset($_POST['name']) && isset($_POST['link']) && isset($_POST['img']) && isset($_POST['ch']) && isset($_POST['mn'])) {
$rekl = mysql_fetch_assoc(mysql_query("SELECT * FROM `rekl` WHERE `sel` = '$sel' AND `id` = '" . intval($_GET['set']) . "' LIMIT 1"));
$ch = intval($_POST['ch']);
$mn = intval($_POST['mn']);
if ($rekl['time_last'] > time()) {
$time_last = $rekl['time_last'] + $ch * $mn * 60 * 60 * 24;
} else {
$time_last = time() + $ch * $mn * 60 * 60 * 24;
}
$link = stripcslashes(htmlspecialchars($_POST['link']));
$name = stripcslashes(htmlspecialchars($_POST['name']));
$img = stripcslashes(htmlspecialchars($_POST['img']));
if (isset($_POST['dop_str']) && $_POST['dop_str'] == 1) {
$dop_str = 1;
} else {
$dop_str = 0;
}
mysql_query("UPDATE `rekl` SET `time_last` = '$time_last', `name` = '$name', `link` = '$link', `img` = '$img', `dop_str` = '$dop_str' WHERE `id` = '" . intval($_GET['set']) . "'");
msg('Рекламная ссылка изменена');
header("Refresh: 1; url=?sel=$sel");
echo "<div class='list-group-item'>";
echo "<a href='?sel=$sel'><i class='material-icons'>keyboard_backspace</i> Текущая позиция</a><br />";
echo "<a href='?'><i class='material-icons'>keyboard_backspace</i> Список рекламы</a>";
echo "</div>";
} elseif (isset($_GET['del']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `rekl` WHERE `sel` = '$sel' AND `id` = '" . intval($_GET['del']) . "'"), 0)) {
mysql_query("DELETE FROM `rekl` WHERE `id` = '" . intval($_GET['del']) . "' LIMIT 1");
msg('Рекламная ссылка удалена');
header("Refresh: 1; url=?sel=$sel");
echo "<div class = 'list-group-item'>";
echo "<a href = '?sel=$sel'><i class='material-icons'>keyboard_backspace</i> Текущая позиция</a><br />";
echo "<a href = '?'><i class='material-icons'>keyboard_backspace</i> Список рекламы</a><br />";
echo "</div>";
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `rekl` WHERE `sel` = '$sel'"), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
if (isset($_GET['set']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `rekl` WHERE `sel` = '$sel' AND `id` = '" . intval($_GET['set']) . "'"), 0)) {
$rekl = mysql_fetch_assoc(mysql_query("SELECT * FROM `rekl` WHERE `sel` = '$sel' AND `id` = '" . intval($_GET['set']) . "'"));
echo '<div class="card">';
echo "<div class='card-header'>Редактирование рекламы <a style='float:right;color: grey;' href = 'rekl.php?sel=$sel&page=$page'><small>Закрыть</small></a></div>";
echo "<form class='card-block' name='rekl' method='POST' action='?sel=$sel&set=$rekl[id]&page=$page'>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='name' name='name' length='100' type='text' value='$rekl[name]' class='validate'>";
echo "<label for='name'>Название</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='link' name='link' length='100' type='text' value='$rekl[link]' class='validate'>";
echo "<label for='link'>Ссылка</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='img' name='img' length='100' type='text' value='$rekl[img]' class='validate'>";
echo "<label for='img'>Картинка</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s4'>";
echo "<input id='ch' name='ch' type='text' value='1' class='validate'>";
echo "<label for='ch'>" . ($rekl['time_last'] > time() ? 'Продлить на' : 'Продлить до') . "</label>";
echo "</div>";
echo "<div class='input-field col s5'>";
echo "<select class='browser-default' name = 'mn'>";
echo "<option value = '1' selected = 'selected'>Дней</option>";
echo "<option value = '7'>Недель</option>";
echo "<option value = '31'>Месяцев</option>";
echo "</select>";
echo "</div>";
echo "</div>";
if ($rekl['dop_str'] == 1) {
$dop = " checked='checked'";
} else {
$dop = NULL;
}
echo "<div class='switch'>";
echo "<label><input type='checkbox' $dop name='dop_str' value='1'><span class='lever'></span>Доп. страница</label>";
echo "</div><br />";
echo "<button class = 'waves-effect waves-light btn'><i class='material-icons'>save</i> Сохранить</button>";
echo "</form>";
echo "</div>";
}
$start = $set['p_str'] * $page - $set['p_str'];
$q = mysql_query("SELECT * FROM `rekl` WHERE `sel` = '$sel' ORDER BY `time_last` DESC LIMIT $start, $set[p_str]");
if ($k_post == 0) {
echo "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<i class='material-icons'>feedback</i> Нет результатов";
echo "</div>";
}
while ($post = mysql_fetch_assoc($q)) {
$title = $post['img'] ? "<a href='$post[img]'>[баннер]</a>" : $post['name'];
echo "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<div style='float:right;' id='hides'>";
echo "<a href='?sel=$sel&set=$post[id]&page=$page' title='Редактировать'><i class='material-icons'>edit</i></a> ";
echo "<a href='?sel=$sel&del=$post[id]&page=$page' title='Удалить'><i class='material-icons'>delete</i></a>";
echo "</div>";
echo "<i class='material-icons'>layers</i> $title<br />";
echo "<font color='grey'><small>";
if ($post['time_last'] > time()) {
echo date::time($post['time_last']) . "<br />";
} else {
echo "Срок показа истек<br />";
}
echo "Ссылка: <a href = '$post[link]' title = '$title'>$post[link]</a><br />";
if ($post['img']) {
echo "Баннер: $post[img]<br />";
}
if ($post['dop_str']) {
echo "Переходов: $post[count]<br />";
}
echo "</small></font>";
echo "</div>";
}
if ($k_page > 1) {
echo "<div class='list-group-item'>";
str("rekl.php?sel=$sel&", $k_page, $page);
echo "</div>";
}
if (isset($_GET['new'])) {
echo '<div class="card">';
echo "<div class='card-header'>Добавление рекламы <a style = 'float:right;color: grey;' href = '?sel=$sel&$passgen'><small>Закрыть</small></a></div>";
echo "<form class='card-block' name='name' method='POST' action='?sel=$sel&add&$passgen'>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='name' name='name' length='100' type='text' value='' class='validate'>";
echo "<label for='name'>Название</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='link' name='link' length='100' type='text' value='' class='validate'>";
echo "<label for='link'>Ссылка</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s12'>";
echo "<input id='img' name='img' length='100' type='text' value='' class='validate'>";
echo "<label for='img'>Картинка</label>";
echo "</div>";
echo "</div>";
echo "<div class='row'>";
echo "<div class='input-field col s4'>";
echo "<input id='ch' name='ch' type='text' value='1' class='validate'>";
echo "<label for='ch'>Срок действия</label>";
echo "</div>";
echo "<div class='input-field col s5'>";
echo "<select class='browser-default' name = 'mn'>";
echo "<option value = '1' selected = 'selected'>Дней</option>";
echo "<option value = '7'>Недель</option>";
echo "<option value = '31'>Месяцев</option>";
echo "</select>";
echo "</div>";
echo "</div>";
echo "<div class='switch'>";
echo "<label><input type='checkbox' checked='checked' name='dop_str' value='1'><span class='lever'></span>Доп. страница</label>";
echo "</div><br />";
echo "<button class='waves-effect waves-light btn'>Добавить</button>";
echo "</form>";
echo "</div>";
}
echo "<div class='list-group-item' style='margin-top: 5px;margin-bottom: 5px;'>n";
echo "<a href='?new&sel=$sel'><i class='material-icons'>add</i> Добавить рекламу</a>";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';
}
$set['title'] = 'Реклама';
require_once H . 'sys/inc/thead.php';
aut();
err();
#Навигация
echo "<nav class='navbar navbar-light' style='background-color: #607D8B; color: #fff;'>";
echo "<ul class='nav navbar-nav'>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/'><i class='material-icons'>home</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/panel/'>Панель управления</a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link'><i class='material-icons'>keyboard_arrow_right</i></a></li>";
echo "<li class='nav-item' style='margin-left: 1px;'><a class='nav-link' href='/panel/rekl.php'>Реклама и баннеры</a></li>";
echo "</ul>";
echo "</nav>";
echo "<div class='collection'>";
echo "<a href='?sel=1' class='collection-item'><i class='material-icons'>keyboard_arrow_right</i> Вверх сайта</a>";
echo "<a href='?sel=2' class='collection-item'><i class='material-icons'>keyboard_arrow_right</i> На главной</a>";
echo "<a href='?sel=3' class='collection-item'><i class='material-icons'>keyboard_arrow_right</i> Низ сайта (главная)</a>";
echo "<a href='?sel=4' class='collection-item'><i class='material-icons'>keyboard_arrow_right</i> Низ сайта (остальные)</a>";
echo "</div>";
require_once H . 'sys/inc/tfoot.php';