<?php
include_once 'app/init.inc.php';
require 'app/libs/FunSmarty.php';
require 'app/libs/FunMysql.php';

$smarty = new FunSmarty();
$db = new Mysql('info');

$db->conn();
//$sql="SELECT id,title,thumb,create_at,`desc` FROM info ORDER BY id desc LIMIT 0,32";
$sql="SELECT id,title,thumb,create_at,`desc` FROM info ORDER BY id desc";
$rst=mysqli_query($db->connect,$sql);
while($row=mysqli_fetch_assoc($rst)){
    if(empty($row['desc']))$row['desc']='暂无概述';
    $rows[]=$row;
}

$hots = [];
$hots[] = array_shift($rows);
$hots[] = array_shift($rows);

$smarty->assign('hots',$hots);
$smarty->assign('lists',$rows);

//var_dump($rows);die;

if(empty($_GET['html_generator'])){
    $smarty->display('newsList.tpl');
    die;
}else{
    $content = $smarty->fetch('newsList.tpl', null, null, false);
    //下面将内容写入至一个静态文件
    $fp = fopen('html/news.html', 'w');
    fwrite($fp, $content);
    fclose($fp);
    die;
}