File size: 4.19Kb
<?php
$title='Комментарии';
require"../system/config.php";
require"../system/func.php";
require"../system/head.php";
require"../system/error.php";
$page = abs((int)$_GET['page']);
if(isset($_GET['type'])){$type=prov($_GET['type']);}else{$type='';}
if(isset($_GET['id_wm'])){$id_wm=cifry($_GET['id_wm']);}else{$id_wm='';}
if($type=='news'){ //Новости
$suchwm=mysql_num_rows(mysql_query("select * from news where id_news='$id_wm' limit 1"));
if($suchwm!=0){
$suchkom=1;
}
}
elseif($type=='loads'){ $suchwm=mysql_num_rows(mysql_query("select * from load_files where typer!='dir' and id_file='$id_wm' limit 1")); if($suchwm!=0){$suchkom=1;}}elseif($type=='obmen'){ $suchwm=mysql_num_rows(mysql_query("select * from obmen_files where
id_file='$id_wm' limit 1")); if($suchwm!=0){$suchkom=1;}}elseif($type=='foto'){ $suchwm=mysql_num_rows(mysql_query("select * from photos where id_photo='$id_wm' limit 1"));if($suchwm!=0){$suchkom=1;}}
elseif($type=='codes'){
$suchwm=mysql_num_rows(mysql_query("select * from codes_id where id_c='$id_wm' limit 1"));
if($suchwm!=0){
$suchkom=1;
}}
elseif($type=='downs'){
$suchwm=mysql_num_rows(mysql_query("select * from down_files where id_c='$id_wm' and typer='file' limit 1"));
if($suchwm!=0){
$suchkom=1;
}}
elseif($type=='links'){
$suchwm=mysql_num_rows(mysql_query("SELECT * FROM `link_idy` WHERE `id_link`='$id_wm' LIMIT 1"));
if($suchwm!=0){
$suchkom=1;
}}
elseif($type=='blog'){
$suchwm=mysql_num_rows(mysql_query("SELECT * FROM `blog` WHERE `id`='$id_wm' LIMIT 1"));
if($suchwm!=0){
$suchkom=1;}}
if($suchkom==1 and $id_wm!=0){
switch($mod){
default:
echo'<div class="i">Комментарии<br></div>';
$num=10;
$sforum=mysql_query("SELECT COUNT(*) FROM `koments` WHERE `type`='$type' AND `id_kogo`='$id_wm'");
$vforum=mysql_query("SELECT * FROM `koments` WHERE `type`='$type' AND `id_kogo`='$id_wm' ORDER BY `id_kom` DESC LIMIT $page,$num");
$total=mysql_result($sforum,0);
if($page < 0 || $page > $total) $page = 0;
if ($total < $page + 10) $end = $total;
else $end = $page + 10;
if($total==0){
echo'<div class="p">Пока нет комментариев...<br></div>';
}else{
while($forum=mysql_fetch_array($vforum)){
echo'<div class="p">'.nik_one($forum['id_user']).'<br>'.date_fixed($forum['dater']).'<br>
'.vizual($forum['text']).'<br></div>';
}
strpage($page, 10, $total, 'koments.php','type='.$type.'&id_wm='.$id_wm.'&page='.$page.'&');
} if($vhod==1){echo'<div class="p"><form action="koments.php?mod=3&type='.$type.'&id_wm='.$id_wm.'" method="post">
Текст:<br>
<textarea cols="20" rows="4" name="soob" class="form"></textarea><br>
<input type="submit" value="Добавить" class="but"><br>
</form>
</div>';}
break;
//Добавление кома
case'3':
echo'<div class="i">Новый комментарий<br></div>';
if($vhod==1){
if(isset($_POST['soob'])){
$soob=prov($_POST['soob'],3000);}else{$soob='';}
if(empty($soob) or strlen($soob)<3){
echo'<div class="p">Ошибка! Ваш комментарий слишком короткий!<br>';
}else{
$flud=mysql_num_rows(mysql_query("SELECT * FROM `koments` WHERE `id_user`='$id_user' AND `dater`>'".time()."' AND `type`='$type' AND `id_kogo`='$id_wm'"));
$povtor=mysql_num_rows(mysql_query("SELECT * FROM `koments` WHERE `id_user`='$id_user' AND `text`='$soob' AND `type`='$type' AND `id_kogo`='$id_wm'"));
if($flud==0 and $povtor==0){
$ttimer=time()+10;
mysql_query("INSERT INTO `koments` SET `id_user`='$id_user', `dater`='$ttimer', `text`='$soob', `id_kogo`='$id_wm', `type`='$type'");
mysql_query("UPDATE `users` SET `balls`=`balls`+1 WHERE `id_user`='$id_user' LIMIT 1");
header("Location: koments.php?id_wm=$id_wm&type=$type&page=$page&isset=yesmess");}else{
echo'<div class="p">Ошибка! Вы слишком часто пытаетесь добавить комментарий либо такой комментарий уже есть в базе!<br>';
}
}
}else{
echo'<div class="p">Ошибка! Добавлять комментарии могут только авторизованные пользователи!<br></div>';
}
break;
}
}else{
echo'<div class="i">Комментарии<br></div>
<div class="p">
Нет комментариев...<br>
</div>';
}
require"../system/foot.php";
?>