<?php

if (!defined('IN_HANFOX')) exit('Access Denied');



$pagename = '网站目录';

$pageurl = '?mod=web';

$tempfile = 'web.html';

$table = $DB->table('websites');



$pagesize = 15;

$curpage = intval($_GET['page']);

if ($curpage > 1) {

	$start = ($curpage - 1) * $pagesize;

} else {

	$start = 0;

	$curpage = 1;

}

		

$area_id = intval($_GET['zid']);

$cache_id = $area_id.'-'.$curpage;



$pageurl .= '&zid='.$area_id;



if (!$smarty->isCached($tempfile, $cache_id)) {

	$smarty->assign('site_title', $pagename.' - '.$options['site_name']);

	$smarty->assign('site_keywords', $options['site_keywords']);

	$smarty->assign('site_description', $options['site_description']);

	$smarty->assign('site_path', get_sitepath('webdir'));

	$smarty->assign('site_rss', get_rssfeed('webdir'));

	

	$where = "w.web_status=3";

	if ($area_id > 0) {

		$area = get_one_areagory($area_id);

		if (!$area) {

			unset($area);

			redirect('?mod=areagory');

		}

		

		$smarty->assign('site_title', $area['area_name'].' - '.$pagename.' - '.$options['site_name']);

		$smarty->assign('site_keywords', !empty($area['area_keywords']) ? $area['area_keywords'] : $options['site_keywords']);

		$smarty->assign('site_description', !empty($area['area_description']) ? $area['area_description'] : $options['site_description']);

		$smarty->assign('site_path', get_sitepath($area['area_mod'], $area['area_id']));

		$smarty->assign('site_rss', get_rssfeed($area['area_mod'], $area['area_id']));

		

		if ($area['area_childcount'] > 0) {

			$where .= " AND w.area_id IN (".$area['area_arrchildid'].")";

			$areagories = get_areagories($area['area_id']);

		} else {

			$where .= " AND w.area_id=$area_id";

			$areagories = get_areagories($area['root_id']);

		}

	} else {

		$areagories = get_areagories();

	}

			

	$websites = get_website_list($where, 'web_ctime', 'DESC', $start, $pagesize);

	$total = $DB->get_count($table.' w', $where);

	$showpage = showpage($pageurl, $total, $curpage, $pagesize);

	

	$smarty->assign('pagename', $pagename);

	$smarty->assign('area_id', $area['area_id']);

	$smarty->assign('area_name', isset($area['area_name']) ? '“'.$area['area_name'].'”网站目录' : $pagename);

	$smarty->assign('areagories', $areagories);

	$smarty->assign('total', $total);

	$smarty->assign('websites', $websites);

	$smarty->assign('showpage', $showpage);

	unset($child_areagory, $websites);

}



smarty_output($tempfile, $cache_id);

?>