<?php

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



$pagename = '地区分类';

$pageurl = '?mod=area';

$tempfile = 'area.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_areapath('area'));

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

	

	$where = "w.web_status=3";

	if ($area_id > 0) {

		$area = get_one_city($area_id);

		if (!$area) {

			unset($area);

			redirect('?mod=city');

		}

		

		$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_areapath($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'].")";

			$areas = get_areas($area['area_id']);

		} else {

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

			$areas = get_areas($area['root_id']);

		}

	} else {

		$areas = get_areas();

	}

			

	$webareas = get_webarea_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('areas', $areas);

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

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

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

	unset($child_city, $webareas);

}



smarty_output($tempfile, $cache_id);

?>