Файл: pages/rewrite_doska.php
Строк: 134
<?php # Created by Up
include_once '../sistem/start.php';
include_once $config['OTS'].'sistem/config.php';
include_once $config['OTS'].'sistem/function.php';
include_once $config['OTS'].'sistem/db.php';
//include_once $config['OTS'].'sistem/users.php';
if(isset($_GET['id']))
{
$id=(int)abs($_GET['id']);
if(mysql_num_rows($sql=mysql_query('SELECT * FROM `users` where `id`=''.$id.'' LIMIT 1;'))>=1)
{
$config['TITLE']='Доска рользователя';
include_once $config['OTS'].'sistem/head.php';
$msg=(int)abs($_GET['msg']);
if(isset($_SESSION['id']) and isset($_SESSION['pass']) and $_SESSION['id']==$id and $_SESSION['adm_rezim']==1)
{
switch($_GET['act'])
{
case 'unset':
mysql_unbuffered_query('DELETE FROM `kom` WHERE `id`=''.$msg.'' and `admin`=''.$id.'' LIMIT 1;');
print '<span class="yes">Сообщение удалено</span><br />';
break;
case 'all_unset':
mysql_unbuffered_query('DELETE FROM `kom` WHERE `admin`=''.$id.'';');
print '<span class="yes">Доска очищена</span><br />';
break;
case 'otvet':
if(mysql_num_rows($sql=mysql_query('SELECT * FROM `kom` where `id`=''.$msg.'' AND `admin`=''.$id.'' LIMIT 1;'))>=1)
{
if(isset($_POST['otvet']))
{
$m=mysql_real_escape_string(filtr($_POST['msg']));
if(!empty($m))
{
mysql_unbuffered_query('UPDATE `kom` SET `otvet`=''.$m.'' WHERE `id`=''.$msg.'' AND `admin`=''.$id.'' LIMIT 1;');
print '<span class="yes">Ответ дан</span><br />';
}
else
$error='Ответ пуст';
}
else
{
$arr=mysql_fetch_assoc($sql);
print '<span class="link">'.$arr['name'].'</span> ('.date('d.m.y/H:i',$arr['time']).')<br /><div class="func">'.$arr['kom'].'<br /></div>';
print '<form method="post" action="doska.php?act=otvet&msg='.$msg.'">';
print 'Ответ (200):<br /><textarea rows="4" cols="15" name="msg">'.$arr['otvet'].'</textarea><br />';
print '<input name="otvet" type="submit" class="submit" value="Ответить" /><br /></form>';
print '<a href="doska.php">Назад</a><br />';
include_once $config['OTS'].'sistem/foot.php';
}
}
else
$error='Сообщение не найдено!';
break;
}
}
if(isset($_POST['go']))
{
if(!$error=get_rand($_POST['code']))
{
$name=mysql_real_escape_string(filtr($_POST['name']));
$msg=mysql_real_escape_string(filtr($_POST['msg']));
if(!empty($name) and !empty($msg))
{
unset($_SESSION['rand']);
mysql_unbuffered_query('insert into `kom` SET
`name`=''.$name.'',
`kom`=''.$msg.'',
`time`=''.time().'',
`admin`=''.$id.'';');
print '<span class="yes">Сообщение успешно добавлено!</span><br />';
}
else
$error='Не заполнено одно из полей!<br />Все поля обязательны к заполнению!';
}
}
print empty($error)?'':'<span class="err">'.$error.'</span><br />';
print '<form method="post" action="doska.php">';
print 'Ваше имя (20):<br /><input type="text" name="name" value="" /><br />';
print 'Сообщение (200):<br /><textarea rows="4" cols="15" name="msg"></textarea><br />';
print 'Код с картинки:<br /><img src="'.$config['home'].'/in/code_'.session_id().'.gif" alt="Загрузка..." /><br /><input type="text" size="6" name="code" value="" /><br />';
print '<input name="go" type="submit" class="submit" value="Написать" /><br /></form>';
$count=mysql_result(mysql_query('SELECT COUNT(*) FROM `kom` WHERE `admin`=''.$id.'';'),0);
if($page=page($count,isset($_GET['page'])?$_GET['page']:1))
{
$sql=mysql_query('SELECT * FROM `kom` WHERE `admin`=''.$id.'' ORDER BY `id` DESC LIMIT '.$page['ot'].','.$_SESSION['kol_sites'].';');
while($arr=mysql_fetch_assoc($sql))
{
print '<span class="link">'.$arr['name'].'</span> ('.date('d.m.y/H:i',$arr['time']).')<br /><div class="func">'.$arr['kom'].'<br />'.(($arr['otvet']!==NULL and !empty($arr['otvet']))?'<b>Ответ:</b> <span class="yes">'.$arr['otvet'].'</span><br />':'').'</div>';
print (isset($_SESSION['id']) and isset($_SESSION['pass']) and $_SESSION['id']==$id and $_SESSION['adm_rezim']==1)?'[<a href="doska.php?act=otvet&msg='.$arr['id'].'">Ответ</a>/<a href="doska.php?act=unset&msg='.$arr['id'].'">Удалить</a>]<br />':'';
}
pages($page['page'],$page['str'],'doska.php?page=');
}
else
print 'Такой страници не существует, или на доске еще не кто не писал!<br />';
print (isset($_SESSION['id']) and isset($_SESSION['pass']) and $_SESSION['id']==$id and $_SESSION['adm_rezim']==1)?'<a href="doska.php?act=all_unset">Очистить</a><br />':'';
print '<a href="index.php">Сайты пользователя</a><br />';
include_once $config['OTS'].'sistem/foot.php';
}
}
#else
{
header('location: ../?act=error&error=404');
exit;
}
?>