<?php
define('SCRIPTNAV', 'article');
require_once './include/inc_common.php';
!defined('IN_MUDDER') && exit('Access Denied');

$articleid = intval($articleid);
$articleid <= 0 && redirect('未知的文章ID。');

$article = $db->get_one("SELECT * FROM {$dbpre}articles a LEFT JOIN {$dbpre}articledata ad 
                        ON(a.articleid=ad.articleid) WHERE a.articleid='$articleid'");
empty($article) && redirect('文章不存在或已删除。');
$article['status'] != 1 && redirect('文章正在审核，请稍候再访问。');

// 商家信息
$item = array();
if($article['shopid']) {
    $row = $db->get_one("SELECT * FROM {$dbpre}shops WHERE sid='{$article[shopid]}'");
    if($row) {
        if(!function_exists('itemToArray')) {
            require_once(MUDDER_ROOT.'./'.$_modules['shop']['directory'].'/include/fun_item.php');
        }
        $item = itemToArray($row);
        unset($row);
    }
}

// 更新pv
$db->update("UPDATE {$dbpre}articles SET pageview=pageview+1 WHERE articleid='$articleid'");
$article['pageview']++;

$subtitle = $article['subject'];
$meta_keywords = sprintf("%s,%s,%s,%s,%s", 
    $article['subject'], 
    $article['author'], 
    $article['keyword'],
    $article['copyfrom'],
    $_config['meta_keywords']
);
$meta_description = sprintf("%s,%s", 
    $article['introduce'],
    $_config['meta_description']
);
require_once MUDDER_ROOT.'header.php';
require_once template($MOD['flag'].'_detail');
footer();
?>