<?php
/*
+-----------------------------------------------------------------------------+
| $Id: article_show.php 2010-05-24 12:37:44Z Bleakwind $
| Show article detail
| Copyright (c) 2003-2010 Bleakwind (www.weaverdream.com)
| http://www.weaverdream.com/
| Release under the GNU Lesser General Public License Version 3 (LGPLv3):
|   http://www.gnu.org/licenses/lgpl.html
+-----------------------------------------------------------------------------+
*/

if (!defined( 'ENTRY_INDEX')){
    echo "<h1>Forbidden</h1><p>You don't have permission to access on this server.</p>";
    exit;
}

if( !preg_match("/^[1-9][0-9]*$/",$sys->get['article_id'])  ){
    $sys->prompt("failed","公告ID发生错误!<!-- article_id_error -->");
}else{
    
    $article_info = $sys->return_article_info($sys->get['article_id']);

    if ( ($article_info['if_enable'] == "2") ||
         ($article_info['if_enable'] == "3" && ($article_info['if_enable_begin'] > $sys->nowtime || $article_info['if_enable_end'] < $sys->nowtime))
       ) {
        $sys->prompt("failed","此公告已经关闭!<!-- article_if_enable_no -->");
    }

    $article_info['detail_list']    = explode("[PAGESPLIT]", $article_info['detail']);
    $article_info['detail_num']     = count($article_info['detail_list']);
    $total_record                   = $article_info['detail_num'];
    $bwpage->set_record_listnum(1);
    $bwpage->set_record($total_record);
    $bwpage->page($CONFIGURE['common']['control_admin']."?act=article&article_id=".$sys->get['article_id']."&pag=%s");
    $article_info['detail_current'] = $article_info['detail_list'][$bwpage->record_listfirst];

    $article_info['attach']     = func::db_select(DB_TABLE_ARTICLE_ATTACH, "*", "article_id=".$article_info['id'], "", "id");

    $sql_data = array(
        "click" => "click+1",
    );
    $result = func::db_update(DB_TABLE_ARTICLE, $sql_data, "id=".$article_info['id']);

    if ($article_info['if_turn'] == "1") {
        $sys->prompt("jump",$article_info['if_turn_url']);
    }
    $t->assign(array(
        "article_info"      => $article_info,
        "pagination"        => $bwpage->pagination,
    ));
}
?>
