<?php
@ ob_start();

@ require ('inc/set/set.php');
header("content-type: text/html; charset=utf-8");

?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<title>地区城市列表</title>
<link id="my_style" rel="stylesheet" type="text/css" href="inc/css/<?php echo $web['sitemode']; ?>/style.css">
<style type="text/css">
<!--

#search { color:#999999; border:1px #EEE solid; padding:5px 10px; text-align:center; margin-bottom:10px; }
#search a {}
.manager_menu { padding:10px 2px; text-align:left; margin-bottom:10px; }
.manager_menu a { white-space:nowrap; font-size:14px; width:123px; white-space:nowrap; overflow:hidden; text-align:center; display:inline-block !important; display:inline; zoom:1; }
-->
</style>
<script language="javascript" src="inc/js/main.js" type="text/javascript"></script>
</head>
<body>
<div id="session" class="session" style="text-align:left;">地区城市列表 [<a href="">更换城市</a>]</div>
<?php
@ require ('inc/city/getcity_seek.php');
$text = '';
if (!empty($_GET['province']) && !empty($_GET['city'])) {
  if (isset($_GET['area'])) {
    if ($_GET['area'] == 'china') {
      if (array_key_exists($_GET['province'], $seek['china']) && in_array($_GET['city'], $seek['china'][$_GET['province']])) {
        $province = $_GET['province'];
        $city = $_GET['city'];
      } else {
        $text .= '参数传递出错！';
      }
    } else {
      if (array_key_exists($_GET['continent'], $seek['international']) && array_key_exists($_GET['province'], $seek['international'][$_GET['continent']]) && in_array($_GET['city'], $seek['international'][$_GET['continent']][$_GET['province']])) {
        $province = $_GET['province'];
        $city = $_GET['city'];
      } else {
        $text .= '参数传递出错！';
      }
    }
  }
  if (isset($province) && isset($city)) {
    setcookie('city', $city, time() + 365 * 24 * 60 * 60, '/');
    setcookie('province', $province, time() + 365 * 24 * 60 * 60, '/');
    header('location: ./');
  }
} else {
  if (empty($_GET['area']) || $_GET['area'] != 'international') {
    $text .= '<div id="search">国内城市 | <a href="?area=international">国外城市</a><br />
<span class="grayword">（查找按Ctrl+F）</span></div>';
    if (empty($_GET['province']) || !array_key_exists($_GET['province'], $seek['china'])) {
      $text_capital = $text_province = '';
      foreach ($seek['china'] as $k => $v) {
        $text_capital .= '<a href="?area=china&province='.urlencode($k).'&city='.urlencode($v[0]).'">'.$v[0].'</a>';
        $text_province .= '<a href="?area=china&province='.urlencode($k).'">'.$k.'</a>';
      }
      $text .= '<div class="list_title"><a class="list_title_in">省会城市</a></div><ul class="manager_menu">'.$text_capital.'</ul><div class="list_title"><a class="list_title_in">各省查找</a></div><ul class="manager_menu">'.$text_province.'</ul>';
    } else {
      $text_city = '';
      foreach ($seek['china'][$_GET['province']] as $v) {
        $text_city .= '<a href="?area=china&province='.$_GET['province'].'&city='.urlencode($v).'">'.$v.'</a>';
      }
      $text .= '<div class="list_title"><a href="?area=china">省区分类</a><a class="list_title_in">'.$_GET['province'].'</a></div><ul class="manager_menu">'.$text_city.'</ul>';
    }
  } else {
    $text .= '<div id="search"><a href="?area=china">国内城市</a> | 国外城市 <br />
<span class="grayword">（查找按Ctrl+F）</span></div>';
    if (empty($_GET['continent']) || !array_key_exists($_GET['continent'], $seek['international'])) {
      $text_continent = '';
      foreach ($seek['international'] as $k => $v) {
        $text_continent .= '<a href="?area=international&continent='.urlencode($k).'">'.$k.'</a>';
      }
      $text .= '<div class="list_title"><a class="list_title_in">洲际</a></div><ul class="manager_menu">'.$text_continent.'</ul>';
    } else {
      if (empty($_GET['country']) || !array_key_exists($_GET['country'], $seek['international'][$_GET['continent']])) {
        $text_country = '';
        foreach ($seek['international'][$_GET['continent']] as $k => $v) {
          $text_country .= '<a href="?area=international&continent='.urlencode($_GET['continent']).'&country='.urlencode($k).'">'.$k.'</a>';
        }
        $text .= '<div class="list_title"><a href="?area=international">洲际</a><a class="list_title_in">'.$_GET['continent'].'国家</a></div><ul class="manager_menu">'.$text_country.'</ul>';

      } else {
        $text_city = '';
        foreach ($seek['international'][$_GET['continent']][$_GET['country']] as $v) {
          $text_city .= '<a href="?area=international&continent='.$_GET['continent'].'&province='.$_GET['country'].'&city='.urlencode($v).'">'.$v.'</a>';
        }
        $text .= '<div class="list_title"><a href="?area=international">洲际</a><a href="?area=international&continent='.urlencode($_GET['continent']).'">'.$_GET['continent'].'国家</a><a class="list_title_in">'.$_GET['country'].'</a></div><ul class="manager_menu">'.$text_city.'</ul>';

      }
    }

  }
  echo $text;
}
?>
</body>
</html>
<?php
@ ob_end_flush();
?>