<?php
/*
+-----------------------------------------------------------------------------+
| $Id: datum_show.php 2010-05-24 12:37:44Z Bleakwind $
| Show admin datum
| 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['datum_id'])  ){
    $sys->prompt("failed","数据仓库信息ID发生错误!<!-- datum_id_error -->");
}else{
    
    $datum_info = $sys->return_datum_info($sys->get['datum_id']);

    if ( ($datum_info['if_enable'] == "2") ||
         ($datum_info['if_enable'] == "3" && ($datum_info['if_enable_begin'] > $sys->nowtime || $datum_info['if_enable_end'] < $sys->nowtime))
       ) {
        $sys->prompt("failed","此数据仓库信息已经关闭!<!-- datum_if_enable_no -->");
    }

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

    $datum_info['attach']     = func::db_select(DB_TABLE_DATUM_ATTACH, "*", "datum_id=".$datum_info['id'], "", "id");

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

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