Location: PHPKode > projects > GENU > GENU-2012.3/comments/reply.php
<?php
// -----------------------------------------------------------------------
//
// $Id: reply.php 177 2012-03-30 15:09:49Z raoul $
//
// Copyright (C) 2003-2012 Raoul Proença
// License: GNU GPL version 3 (see copying.txt file)
// Website: http://www.gnew.fr/
//
// -----------------------------------------------------------------------
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// -----------------------------------------------------------------------

include('./../includes/common.php');

page_header($lang['COMMENTS_REPLY_TITLE']);

// User logged ?
if ($_SESSION['user_id'] != 0)
{
    // Check query
    if (!empty($_GET['comment_id']))
    {
        $sql->query('SELECT ' . TABLE_COMMENTS . '.comment_creation, ' . TABLE_COMMENTS . '.comment_edition, ' . TABLE_COMMENTS . '.comment_subject, ' . TABLE_COMMENTS . '.comment_text, ' . TABLE_COMMENTS . '.news_id, ' . TABLE_COMMENTS . '.story_id, ' . TABLE_USERS . '.user_avatar, ' . TABLE_USERS . '.user_id, ' . TABLE_USERS . '.user_name
                     FROM ' . TABLE_COMMENTS . ', ' . TABLE_USERS . '
                     WHERE ' . TABLE_COMMENTS . '.user_id = ' . TABLE_USERS . '.user_id
                     AND ' . TABLE_COMMENTS . '.comment_id = \'' . $_GET['comment_id'] . '\'');
        $table_comments = $sql->fetch();
        // Check comment
        if (!$table_comments['story_id'])
        {
            error_template($lang['COMMENTS_REPLY_ERROR1']);
        }
        else
        {
            $date_format = get_date_format();
            $date_offset = get_date_offset();
            // ----------------------------------------------------------------
            $sql->query('SELECT ' . TABLE_CATEGORIES . '.category_id, ' . TABLE_CATEGORIES . '.category_image, ' . TABLE_CATEGORIES . '.category_name, ' . TABLE_NEWS . '.news_date, ' . TABLE_NEWS . '.news_source, ' . TABLE_NEWS . '.news_subject, ' . TABLE_NEWS . '.news_text, ' . TABLE_USERS . '.user_id, ' . TABLE_USERS . '.user_name
                         FROM ' . TABLE_CATEGORIES . ', ' . TABLE_NEWS . ', ' . TABLE_USERS . '
                         WHERE ' . TABLE_CATEGORIES . '.category_id = ' . TABLE_NEWS . '.category_id
                         AND ' . TABLE_CATEGORIES . '.category_level IN (\'0\', \'2\')
                         AND ' . TABLE_NEWS . '.news_active = \'1\'
                         AND ' . TABLE_NEWS . '.user_id = ' . TABLE_USERS . '.user_id
                         AND ' . TABLE_NEWS . '.news_id = \'' . $table_comments['news_id'] . '\'');
            $table_news = $sql->fetch();
            $news_date = date($date_format, ($table_news['news_date'] + $date_offset));
            if ($table_news['news_source'])
            {
                $news_source = undo_escape_sequences($table_news['news_source']);
                $news_source = sprintf($lang['NEWS_INDEX_SOURCE'], $news_source);
            }
            else
            {
                $news_source = '<!-- empty -->';
            }
            $news_text = undo_escape_sequences($table_news['news_text']);
            // ----------------------------------------------------------------
            $comment_creation = date($date_format, ($table_comments['comment_creation'] + $date_offset));
            $comment_edition = date($date_format, ($table_comments['comment_edition'] + $date_offset));
            if ($table_comments['comment_edition'])
            {
                $comment_edition = sprintf($lang['COMMENTS_INDEX_EDITION'], $comment_edition);
            }
            else
            {
                $comment_edition = '';
            }
            $comment_text = undo_escape_sequences($table_comments['comment_text']);
            // ----------------------------------------------------------------
            if ($settings['allow_html'] == 0)
            {
                $html_support = $lang['HTML_DISABLED'];
            }
            else
            {
                $html_support = $lang['HTML_ENABLED'];
            }
            $template->set_file('reply', 'comments/reply.htpl');
            $template->set_var(array('ADD' => $lang['ADD'],
                                     'BACK_HOME' => $lang['BACK_HOME'],
                                     'CATEGORY_ID' => $table_news['category_id'],
                                     'CATEGORY_IMAGE' => $table_news['category_image'],
                                     'CATEGORY_NAME' => $table_news['category_name'],
                                     'COMMENT_EDITION' => $comment_edition,
                                     'COMMENT_RELEASE' => sprintf($lang['COMMENTS_REPLY_RELEASE'], $table_comments['user_id'], $table_comments['user_name'], $comment_creation),
                                     'COMMENT_SUBJECT' => $table_comments['comment_subject'],
                                     'COMMENT_TEXT' => $comment_text,
                                     'COMMENTS_REPLY_HEADER' => $lang['COMMENTS_REPLY_HEADER'],
                                     'FORM_COMMENT_SUBJECT' => $lang['FORM_COMMENT_SUBJECT'],
                                     'FORM_COMMENT_TEXT' => $lang['FORM_COMMENT_TEXT'],
                                     'HTML_SUPPORT' => $html_support,
                                     'NEWS_ID' => $table_comments['news_id'],
                                     'NEWS_INDEX_SEND' => $lang['NEWS_INDEX_SEND'],
                                     'NEWS_RELEASE' => sprintf($lang['NEWS_INDEX_RELEASE'], $table_news['user_id'], $table_news['user_name'], $news_date),
                                     'NEWS_SOURCE' => $news_source,
                                     'NEWS_SUBJECT' => $table_news['news_subject'],
                                     'NEWS_TEXT' => $news_text,
                                     'PREVIEW' => $lang['PREVIEW'],
                                     'SMILIES_LIST' => get_smilies_list(0),
                                     'STORY_ID' => $table_comments['story_id'],
                                     'USER_AVATAR' => $table_comments['user_avatar']));
            $template->parse('reply');
        }
    }
    else
    {
        error_template($lang['COMMENTS_REPLY_ERROR1']);
    }
}
else
{
    error_template($lang['COMMENTS_REPLY_ERROR2']);
}

page_footer();

?>
Return current item: GENU