View file uncos/comments.php

File size: 4.39Kb
<?
/*
=============================================
Движок:  SHCMS Engine
=============================================
Название файла: Комментарии к Новостям
=============================================
Official website: http://shcms.ru
=============================================
*/
define('SHCMS', true);
include_once'../system/inc/system_core.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'] = Lang::get('Комментарии: %s',$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)
    {
	    engine::errors(Lang::get('Запрещено добавление комментарий к данной новости.'));
        include_once'../template/foot.php';
        exit();
	}
    if($_POST['submit'])
    {
		$submit = $_POST['submit'];
	}
    if(isset($submit))
    {
	    if($_POST['text'])
        {
		    $text = $_POST['text'];
		}

            if(empty($text))
            {
			    engine::errors(Lang::get('Введите текст комментарии'));
                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()."','".engine::my_esc($text)."')");
        if($comm == true)
	    {
            engine::correct(Lang::get('Комментарий успешно добавлен'));
            header("Refresh: 1; url=?id=$id");
            include_once'../template/foot.php';
            exit;
		}
        else
        {
            engine::errors(Lang::get('Возникла ошибка при добавлении комментарии'));
            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(Lang::get('<strong>Текст комментария:</strong>'),'text','',true);
			$form->submit(Lang::get('Отправить'),'submit');
			$form->submit(Lang::get('Обновить'),'refresh');
			$form ->form_link(DIR_SHCMS.'smile.php',Lang::get('Смайлы'));
			$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').'&nbsp;'.Lang::get('Комментарии не добавлены');
			echo '</div>';
    }

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