View file uncos/comments.php

File size: 4.29Kb
<?
/*
=============================================
Движок:  SHCMS Engine
=============================================
Название файла: Комментарии к Новостям
=============================================
Official website: http://shcms.ru
=============================================
*/
define('SHCMS', true);
include_once'../system/inc/basic_settings.php';
    if($_GET['id'])
	{
	    $id=$_GET['id'];
	}
        $news = mysql_fetch_array(mysql_query("SELECT * FROM `uncos` WHERE `id`='$id'"));
        $news_rows = mysql_query("SELECT * FROM `uncos` WHERE `id` = '$id'");
		
$shcmsengine['title'] = 'Комментарии: '.$news['title'].''; 
include_once'../template/head.php';

$news_list = mysql_fetch_array(mysql_query("SELECT * FROM `uncos` WHERE `id` = '$id'"));

echo '<div class="maintitle mainrazd">'.$news_list['title'].' <span class="mainforum">'.$timedate->times($news_list['time']).'</span></div>';
echo '<div class="maintext">'.processing($news_list['text']).'</div>';
    if($news['komm'] == 0)
    {
	    errors('Запрещено добавление комментарий к данной новости.');
        include_once'../template/foot.php';
        exit();
	}
    if($_POST['submit'])
    {
		$submit = $_POST['submit'];
	}
    if(isset($submit))
    {
	    if($_POST['text'])
        {
		    $text = $_POST['text'];
		}

            if(empty($text))
            {
			    echo '<div class="errors">Введите текст комментарии</div>';
                header("Refresh: 1; url=?id=$id");
                include_once'../template/foot.php';
                exit;
			}


            $comm = mysql_query("INSERT INTO `uncos_comment` (`user_id`,`id_uncos`,`time`,`text`) VALUES ('$user_id','$id','".time()."','".my_esc($text)."')");
        if($comm == true)
	    {
            echo '<div class="actshcms">Комментарий успешно добавлен</div>';
            header("Refresh: 1; url=?id=$id");
            include_once'../template/foot.php';
            exit;
		}
        else
        {
            echo '<div class="actshcms">Возникла ошибка при добавлении комментарии</div>';
            header("Refresh: 1; url=?id=$id");
            include_once'../template/foot.php';
            exit;
        }

    }
    else
    {
        if($user_id) {	
		echo '<div class="maintext">';
			$form = new form("?id=$id");
			$form->textarea('<strong>Текст комментария:</strong>','text','',true);
			$form->submit('Отправить','submit');
			$form->submit('Обновить','refresh');
			$form ->form_link(DIR_SHCMS.'smile.php','Смайлы');
			$form->finish();
			echo '</div>';
		}
    }
	
    $allfield = mysql_result(mysql_query("SELECT COUNT(*) FROM `uncos_comment` WHERE `id_uncos`='$id'"),0);
    $newlist = new Navigation($allfield,10,true); 
    $where_comm = mysql_query("SELECT * FROM `uncos_comment` WHERE `id_uncos`='$id' ORDER BY `id` ". $newlist->limit()."");
    if(mysql_num_rows($where_comm) > 0)
    {
		 $num_post=0;
        while($whire_comm = mysql_fetch_array($where_comm))
        {
		$num_post++;
            $users = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '$whire_comm[user_id]' "));
            echo '<div class="maintitle"> <font color="#0386C3">#'.$num_post.'</font>&nbsp;';
			users_profile($users['id']);
            list_users($users_id);
			
            echo '<span class="maintime">'.$timedate->times($whire_comm['time']).'</span></div>';
            echo '<div class="maintext">'.processing($whire_comm['text']).'';
			if($user4['team'] == 6){
			    echo '<span style="float:right">
			    <a href="delete.php?id='.$whire_comm['id'].'"><img src="../template/icon/delete.png"/></a></span>';
			}
			echo '</div>';
        }
		
            echo '<div class="pages">';
            echo $newlist->pagination('id='.$id.'');
            echo '</div>';
    }
    else
    {
		echo '<div class="maintext">';
        echo SHCMS_core::img_shcms('../template/icon/empty.png').'Комментарии не добавлены';
			echo '</div>';
    }

echo '<div class="link_str"><a href="/uncos/">Назад</div>';
include_once'../template/foot.php';
?>