<?php
/**
* FILE_NAME : index.php
*
* @copyright Copyright (c) www.shuangyulin.com
* @author 双鱼林设计
* @package 前台首页
* @subpackage
* @version QQ:287307421或254540457
*/

require_once './include/common.inc.php';

/*--  对一些系统变量赋值  --*/
$template->assign("css_root",$css_root);
$template->assign("web_url",$web_url);
$template->assign("sitename",$_CFG['sitename']);

/*--  查询出导航栏  --*/
$sql = $query = '';
$sql = "SELECT * FROM {$dbprefix}navgation ORDER BY displayorder";
$query = $DB->query($sql);
while ($row = $DB->fetch_array($query)) {
	if ($row['oldurl']) {
		$navs['url'] = $row['oldurl'];
	}
	$navs[] = $row;
}
$template->assign("navs",$navs);

/*--  查询出最新新闻  --*/
$sql = "SELECT * FROM {$dbprefix}articles ORDER BY dateline DESC";
$query = $DB->query($sql);
while ($row = $DB->fetch_array($query)) {
	$row['dateline'] = formatdate("m-d",$row['dateline']);
	$row['title'] = cutstr($row['title'],25);
	$news[] = $row;
}
$template->assign("news",$news);

/*--  查询出网站公告  --*/
$sql = "SELECT * FROM {$dbprefix}announcements ORDER BY postdate DESC";
$query = $DB->query($sql);
while ($row = $DB->fetch_array($query)) {
	$row['postdate'] = formatdate("m-d",$row['postdate']);
	$anno[] = $row;
}
$template->assign("anno",$anno);

/*--  查询友情链接  --*/
$sql = "SELECT * FROM {$dbprefix}friendlinks ORDER BY displayorder";
$query = $DB->query($sql);
while ($row = $DB->fetch_array($query)) {
	$row['logo'] = $web_url.substr($row['filepath'],3).$row['logo'];
	$flink[] = $row;
}
$template->assign("flink",$flink);

/*--  判断是否登录  --*/
$is_login = $_COOKIE['username'] ? 1 : 0;
if ($is_login) {
	$username = $_COOKIE['username'];
}

$template->assign("is_login",$is_login);
$template->assign("username",$username);

$template->display("index.html");

?>