Файл: go9010.ru/moduls/panel.php
Строк: 97
<?php
$title = 'Админ-Панель';
require ('../core/sys.php');
require ('../core/head.php');
$log = htmlspecialchars($_COOKIE['login']);
$pass = htmlspecialchars($_COOKIE['password']);
switch($_GET['case']){
default;
if($log != $admlogin || $pass != $admpass){
header('Location: /panel/login/');
exit;
}
?><div class="title">Админ-Панель</div>
<a href="/panel/view/"><div class="menu"> Просмотр площадок</div></a>
<a href="/panel/add/"><div class="menu"> Добавить площадку</div></a><?
break;
case 'login':
if($log == $admlogin and $pass == $admpass){
header('Location: /panel/');
exit;
}
?><div class="title"> Админ-Панель</div><?
if(isset($_POST['login'])){
$login = htmlspecialchars($_POST['login']);
$password = htmlspecialchars($_POST['password']);
if(empty($login)){
$_SESSION['message'] = 'Введите логин';
header('Location: /panel/login/');
exit;
}
if(empty($password)){
$_SESSION['message'] = 'Введите пароль';
header('Location: /panel/login/');
exit;
}
if($login != $admlogin || $password != $admpass){
$_SESSION['message'] = 'Неверный логин или пароль';
header('Location: /panel/login/');
exit;
}
setcookie('login', $login, time()+86400*365, '/');
setcookie('password', $password, time()+86400*365, '/');
header('Location: /panel/');
exit;
}
?><form class="menu" action="" method="post"> Логин:<br/><input type="text" name="login" maxlength="50" value=""/><br/> Пароль:<br/><input type="password" name="password" maxlength="50" value=""/><br/><input type="submit" value="Войти"></form><?
break;
case 'add':
if($log != $admlogin || $pass != $admpass){
header('Location: /panel/login/');
exit;
}
if(isset($_POST['day'])){
$day = abs(intval($_POST['day']));
$time = $day*86400+time();
$url = htmlspecialchars($_POST['url']);
$sql = $db->prepare('INSERT INTO `platform` (`url`,`time`,`status`) VALUES (?,?,?)');
$sql -> execute([$url,$time,'on']);
$_SESSION['message'] = 'Площадка успешно добавлена';
header('Location: /panel/add/');
exit;
}
?><div class="title"><a href="/panel/"> Админ-Панель</a> | Новая площадка</div><form class="menu" method="POST"
action="">
<table width="100%" border="0px"><tbody><tr>
<table width="100%" border="0px"><tbody><tr><td
width="30%" height="35px"><center><input
type="number" name="day"
value="3"></center></td>
<td width="auto" align="left"><small>Кол-во дней (1 дн/
1 руб.)</small></td></tr></tbody></table>
<table width="100%" border="0px"><tbody><tr>
<td width="30%" height="35px"><center><input
type="url" name="url" value="http://go9010.ru"></center></td>
<td width="auto" align="left"><small>Адрес сайта (C
http://)</small></td></tr></tbody></table>
<center><input type="submit"
name="submit" value="Добавить"></center></form><?
break;
case 'del':
if($log != $admlogin || $pass != $admpass){
header('Location: /panel/login/');
exit;
}
$id = abs(intval($_GET['id']));
$del = $db->prepare('DELETE FROM `platform` WHERE `id` = ?');
$del -> execute([$id]);
header('Location: /panel/view/');
exit;
break;
case 'view':
if($log != $admlogin || $pass != $admpass){
header('Location: /panel/login/');
exit;
}
?><div class="title"><a href="/panel/"> Админ-Панель</a> | Просмотр площадок</div><?
$kount = $db->prepare('SELECT * FROM `platform`');
$kount -> execute();
$kount = $kount -> rowCount();
if($kount == 0){
?><div class="menu"><center>Пусто</center></div><?
}
$all = $db->prepare('SELECT * FROM `platform` ORDER BY `id` DESC');
$all -> execute();
$all = $all -> fetchAll();
foreach($all as $row){
?>
<div class="menu"><b>URL:</b> <img
src="http://www.google.com/s2/favicons?domain=<?=$row['url'];?>"> <a href="<?=$row['url'];?>"><?=$row['url'];?></a><br>
<strong>Активна до: </strong> <?=vremja($row['time']);?><br>
<a href="/panel/?case=del&id=<?=$row['id'];?>"> Удалить </a></div><?
}
break;
}
require ('../core/foot.php');
?>