Просмотр файла gb/admin.php

Размер файла: 3.6Kb
<?php
$title='Админ панель';
include '../system/func.php';
include '../system/head.php';
echo '<div class="title">'.$title.'</div>';
switch($act){
default:
if ($gb_pass == $cgb_pass){
header('Location: index.php');
exit;
}
if (isset($_POST['ok'])){
$pass=check($_POST['pass']);
if (empty($pass)){
$err='Не введён пароль';
}
elseif ($pass != $gb_pass){
$err='Не верный пароль';
}
if (!empty($err)){
err($err);
}else{
SetCookie('gb_pass',$pass,time()+3600*24*365,'/');
header('Location: index.php');
exit;
}
}
echo '<div class="menu"><form method="post">Пароль:<br/><input type="password" name="pass"><br/><input type="submit" name="ok" value="Войти"></form></div>';
break;
case 'delete':
if ($gb_pass != $cgb_pass){
header('Location: index.php');
exit;
}
$arr=file('gb.dat');
if (!isset($arr[$id])){
header('Location: index.php');
exit;
}
if (isset($_GET['ok'])){
unset($arr[$id]);
$f=fopen('gb.dat','w');
$d=implode('',$arr);
fputs($f,$d);
fclose($f);
header('Location: index.php');
exit;
}else{
echo '<div class="menu">Точно удалить данное сообщение?<br/><center><a href="index.php">Нет</a> | <a href="?act=delete&id='.$id.'&ok">Да</a></center></div>';
}
break;
case 'edit':
if ($gb_pass != $cgb_pass){
header('Location: index.php');
exit;
}
$arr=file('gb.dat');
if (!isset($arr[$id])){
header('Location: index.php');
exit;
}
include 'smiles.php';
$post=unserialize($arr[$id]);
if (isset($_POST['ok'])){
$data['nick']=check($_POST['nick']);
$data['text']=check($_POST['text'], true);
$data['time']=abs(intval($post['time']));
$data['ua']=check($post['ua']);
$data['ip']=check($post['ip']);
if(empty($data['nick']) || empty($data['text'])){
err('Не заполнено поле');
}else{
$data['text']=str_replace($sstr,$simg,$data['text']);
preg_match_all('!(http://[\S]+)([\s]|$)!i',$data['text'],$url);
for($s=0; $s<count($url); $s++){
if (!preg_match('|http://'.$_SERVER['HTTP_HOST'].'|i',$url['1'][''.$s.''])){
$data['text']=str_replace($url['1'][''.$s.''].''.$url['2'][''.$s.''],'<a href="'.$url['1'][''.$s.''].''.$url['2'][''.$s.''].'">Ссылка</a>',$data['text']);
}
}
$arr[$id]=serialize($data)."\n";
$f=fopen('gb.dat','w');
fputs($f,implode('',$arr));
fclose($f);
header('Location: index.php');
exit;
}
}
$post['text']=str_replace($simg,$sstr,$post['text']);
$post['text']=preg_replace('#<a href="(.*)">Ссылка</a>#sU','\1',$post['text']);
$post['text']=str_replace('<br />',"\n",$post['text']);
echo '<div class="menu"><form method="post">Ник:<br/><input type="text" name="nick" value="'.$post['nick'].'"><br/>Сообщение:<br/><textarea name="text" rows="3" cols="20">'.$post['text'].'</textarea><br/><input type="submit" name="ok" value="Изменить"></form></div>';
break;
case 'inf':
if ($gb_pass != $cgb_pass){
header('Location: index.php');
exit;
}
$arr=file('gb.dat');
if (!isset($arr[$id])){
header('Location: index.php');
exit;
}
$inf=unserialize($arr[$id]);
echo '<div class="menu"><b>ip:</b> '.(!empty($inf['ip'])?$inf['ip']:'Не известно').'<br/><b>User-Agent:</b> '.(!empty($inf['ua'])?$inf['ua']:'Не известно').'</div>';
break;
case 'exit':
if ($gb_pass != $cgb_pass){
header('Location: index.php');
exit;
}
if (isset($_GET['ok'])){
SetCookie('gb_pass', '', time(), '/');
header('Location: index.php');
exit;
}
echo '<div class="menu">Точно выйти из админки?<br/><center><a href="index.php">Нет</a> | <a href="?act=exit&ok">Да</a></center></div>';
break;
}
include '../system/foot.php';
?>