Просмотр файла msg.php

Размер файла: 4.48Kb
<?php
$us=$_GET['id'];
$ps=$_GET['ps'];
$id_rz=intval($_GET['id_rz']);
$id_tm=intval($_GET['id_tm']);
$deler=intval($_GET['deler']);

$us=mysql_escape_string(htmlspecialchars(trim($us)));
$ps=mysql_escape_string(htmlspecialchars(trim($ps)));
include("ini.php");
$act=bug($_POST['act']);
$login = autorize();
if($login) {
@mysql_query("update `c_users` set `ltime`='".time()."', `room`='forum', `nev`='0' where `id`='".$id."';");
}
if($id_rz&&$id_tm){
if($deler) {
$del_foto = @mysql_query("SELECT * FROM `c_forum_msg` WHERE `id`='".$deler."';");
$d_fit = @mysql_fetch_array($del_foto);
$kto_df = $d_fit['kto'];
$liven_df = $d_fit['liven'];
if(($kto_df==$id)or(($liven_us>3)&&($liven_df<$liven_us))){
@mysql_query("delete from `c_forum_msg` WHERE `id`='".$deler."';");
}
}



$razdel_zagr = @mysql_query("SELECT * FROM `c_forum_razdel` WHERE `id`='".$id_rz."';");
$osn_razd = @mysql_fetch_array($razdel_zagr);
$kategor_rz = $osn_razd['kategor'];
if($kategor_rz==3){
if($liven_us<3)header("Location:index.php?f=$f");
}
if($kategor_rz==2){
if(!$id_us)header("Location:index.php?f=$f");
}
$tema_viv = @mysql_query("SELECT * FROM `c_forum_tema` WHERE `id`='".$id_tm."';");
$itog_tem = mysql_fetch_array($tema_viv);
include("head.php");
if($itog_tem['utwerdil']=='0')

if($login) {
echo "Вы вошли как $nik_us<br/>";
}else{
echo "Вы не Авторизированны<br/>";
}
if($itog_tem['sostojan']=='1'){echo "Тема закрыта Администрацией"; }else{
if($itog_tem['utwerdil']=='0'){
if(($itog_tem['kto']==$id)or($liven_us>3)) echo "<a href=\"add_msg.php?f=$f&amp;id=$id&amp;ps=$ps&amp;id_rz=$id_rz&amp;id_tm=$id_tm\">Ответить</a><br/>";
else
echo "Данная тема еще не утверждена Администрацией";
}else{
if($login) echo "<a href=\"add_msg.php?f=$f&amp;id=$id&amp;ps=$ps&amp;id_rz=$id_rz&amp;id_tm=$id_tm\">Ответить</a><br/>";}}

$query = @mysql_query("SELECT COUNT(*) FROM `c_forum_msg` WHERE `razdel`='".$id_rz."' and `tema`='".$id_tm."';");
$all = @mysql_result($query, 0);
if(isset($_GET['s'])) $s = intval($_GET['s']);
else $s = 0;
if($s < 0) $s = 0;
if($s > $all) $s = 0;
$c = $s + 1;
if($all==0) $body=$body."<br/>Данная тема ПУСТА<br/><br/>";
$mgs_viv = @mysql_query("SELECT * FROM `c_forum_msg` WHERE `razdel`='".$id_rz."' and `tema`='".$id_tm."' ORDER BY `id` LIMIT $s, 13;");
while($itog_mgs = mysql_fetch_array($mgs_viv))
{
$id_mg = $itog_mgs['id'];
$kto_mg = $itog_mgs['kto'];
$liven_mg = $itog_mgs['liven'];
$msg_mg = $itog_mgs['msg'];
$date_mg = $itog_mgs['date'];
$user_kto=@mysql_query("SELECT * FROM `c_users` WHERE `id` = '".$kto_mg."';");
$kto_user=@mysql_fetch_array($user_kto);


if($login){
echo "<hr/>";
if(($kto_mg==$id)or(($liven_us>3)&&($liven_mg<$liven_us)))
echo "<a href=\"?f=$f&amp;id=$id&amp;ps=$ps&amp;id_rz=$id_rz&amp;id_tm=$id_tm&amp;deler=$id_mg\">X</a> ";
echo "<a href=\"inslide.php?f=$f&amp;id=$id&amp;ps=$ps&amp;id_an=".$kto_user['id']."\">".$kto_user['nik']."</a> [<b>$date_mg</b>]&lt; $msg_mg";
}else{
echo "<hr/>";
echo "".$kto_user['nik']." [<b>$date_mg</b>]&lt; $msg_mg";}
$c++;
}

echo "<hr/>";
if($login) {
if ($s > 0)  echo "<a href=\"?f=$f&amp;id=$id&amp;ps=$ps&amp;id_rz=$id_rz&amp;id_tm=$id_tm&amp;s=".($s-13)."\">&lt;&lt;&lt;&lt;</a> |";
if ($all > $s + 13)  echo "| <a href=\"?f=$f&amp;id=$id&amp;ps=$ps&amp;id_rz=$id_rz&amp;id_tm=$id_tm&amp;s=".($s+13)."\">&gt;&gt;&gt;&gt;</a>";
}else{
if ($s > 0)  echo "<a href=\"?f=$f&amp;s=".($s-13)."\">&lt;&lt;&lt;&lt;</a> |";
if ($all > $s + 13)  echo "| <a href=\"?f=$f&amp;s=".($s+13)."\">&gt;&gt;&gt;&gt;</a>";
}
if($all>15)echo "<br/><br/>";
if($itog_tem['sostojan']=='0'){
if($itog_tem['utwerdil']=='0'){
if(($itog_tem['kto']==$id)or($liven_us>3)) echo "<a href=\"add_msg.php?f=$f&amp;id=$id&amp;ps=$ps&amp;id_rz=$id_rz&amp;id_tm=$id_tm\">Ответить</a><br/>";
}else{
if($login) echo "<a href=\"add_msg.php?f=$f&amp;id=$id&amp;ps=$ps&amp;id_rz=$id_rz&amp;id_tm=$id_tm\">Ответить</a><br/>";}}
if($login)
echo "<a href=\"temi.php?f=$f&amp;id=$id&amp;ps=$ps&amp;id_rz=$id_rz\">Темы</a><br/>";
else
echo "<a href=\"temi.php?f=$f&amp;id_rz=$id_rz\">Темы</a><br/>";
if($login)
echo "<a href=\"index.php?f=$f&amp;id=$id&amp;ps=$ps\">Разделы</a><br/>";
else
echo "<a href=\"index.php?f=$f\">Разделы</a><br/>";
include("foot.php");
}else{
if($login)
header("Location:index.php?f=$f&id=$id&ps=$ps");
else
header("Location:index.php?f=$f");
}
?>