Location: PHPKode > projects > Gnew > Gnew-2013.1/articles/read.php
<?php
// -----------------------------------------------------------------------------
// $Id: read.php 676 2013-03-27 13:38:34Z raoul $
//
// Copyright (C) 2013 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.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
// -----------------------------------------------------------------------------

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

page_header($lang['ARTICLES_READ']);

if (!empty($_GET['article_id']) && string_is_int($_GET['article_id']))
{
    $sql->query('SELECT t1.category_id, t1.user_id, t1.article_subject, t1.article_text, t1.article_creation, t1.article_edition, t1.edition_id, t1.edition_name, t2.category_image, t2.category_name, t3.user_name
                 FROM ' . TABLE_ARTICLES . ' AS t1
                 INNER JOIN ' . TABLE_CATEGORIES . ' AS t2
                             ON (t2.category_id = t1.category_id AND t2.category_level IN (\'1\', \'4\'))
                 INNER JOIN ' . TABLE_USERS . ' AS t3
                             ON (t3.user_id = t1.user_id)
                 WHERE t1.article_id = \'' . $_GET['article_id'] . '\'');
    $table_articles = $sql->fetch();
    // Check article
    if (!$table_articles['article_subject'])
    {
        error_template($lang['ERROR_NO_DATA']);
    }
    else
    {
        if ($table_articles['article_edition'])
        {
            $article_edited = sprintf($lang['EDITED_BY'], $table_articles['edition_id'], $table_articles['edition_name'], format_date($table_articles['article_edition']));
        }
        else
        {
            $article_edited = '';
        }
        $article_text = undo_escape_sequences($table_articles['article_text']);
        $template->set_file('read', 'articles/read.htpl');
        $template->set_var(array('ARTICLE_EDITED' => $article_edited,
                                 'ARTICLE_POSTED' => sprintf($lang['POSTED_BY'], $table_articles['user_id'], $table_articles['user_name'], format_date($table_articles['article_creation'])),
                                 'ARTICLE_SUBJECT' => $table_articles['article_subject'],
                                 'ARTICLE_TEXT' => $article_text,
                                 'CATEGORY_ID' => $table_articles['category_id'],
                                 'CATEGORY_IMAGE' => $table_articles['category_image'],
                                 'CATEGORY_NAME' => $table_articles['category_name']));
        $template->parse('read', null, false, array(TABLE_ARTICLES, TABLE_CATEGORIES, TABLE_USERS));
    }
}
else
{
    error_template($lang['ERROR_NO_DATA']);
}

page_footer();

?>
Return current item: Gnew