<?php
include_once 'app/init.inc.php';
require 'app/libs/FunSmarty.php';
require 'app/libs/FunMysql.php';

$smarty = new FunSmarty();
$db = new Mysql('info');

$vo = $db->find($_GET['id']);
$smarty->assign('newsInfo', $vo);


if (empty($_GET['html_generator'])) {
  $smarty->display('newsDetail.tpl');
  die;
} else {

  if (!file_exists('html/news')) {
    mkdir('html/news');
  }
  if (!file_exists('html/news/' . $_GET['id'] . '.html')) {
    $content = $smarty->fetch('newsDetail.tpl', null, null, false);
    //下面将内容写入至一个静态文件
    $fp = fopen('html/news/' . $_GET['id'] . '.html', 'w');
    fwrite($fp, $content);
    fclose($fp);
  }

  die;
}