city.inc.php
2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* DZAPP Haodai City Switcher
*
* @copyright (c) 2013-2014 DZAPP. (http://www.dzapp.cn)
* @author BranchZero <branchzero@gmail.com>
*/
!defined('IN_DISCUZ') && exit('Access Denied');
include_once DISCUZ_ROOT.'./data/dzapp_haodai_config.php';
include_once DISCUZ_ROOT.'./source/plugin/dzapp_haodai/haodai.api.class.php';
include_once DISCUZ_ROOT.'./source/plugin/dzapp_haodai/dzapp_haodai.func.php';
@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_setting.php';
if(!@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_city.php' || TIMESTAMP - filemtime(DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_city.php') > $var['refreshtime']){
$client = new HaoDaiClient(HD_AKEY, HD_SKEY, $hd_token['access_token']);
$client->set_debug(0);
$result = $client->get_xindai_zones();
$zonelist = $result['items'];
if(count($zonelist) > 0){
$zones = array();
foreach($zonelist as $value){
if($value['s_EN'] == 'www') continue;
$value['zone_name'] = diconv($value['zone_name'], 'UTF-8', CHARSET);
$value['Province'] = diconv($value['Province'], 'UTF-8', CHARSET);
$value['area'] = diconv($value['area'], 'UTF-8', CHARSET);
$zones[$value['s_EN']] = $value['zone_name'];
$zonesort['provinces'][$value['Province']][$value['s_EN']] = $value['zone_name'];
$zonesort['letter_raw'][$value['letter']][$value['s_EN']] = $value['zone_name'];
$zonesort['area'][$value['area']][$value['s_EN']] = $value['zone_name'];
}
foreach(range('A', 'Z') as $letter) {
if(!empty($zonesort['letter_raw'][$letter])) $zonesort['letter'][$letter] = $zonesort['letter_raw'][$letter];
}
require_once libfile('function/cache');
writetocache('dzapp_haodai_city', getcachevars(array('zones' => $zones)));
writetocache('dzapp_haodai_city_sort', getcachevars(array('zonesort' => $zonesort)));
}else{
showmessage('dzapp_haodai:callback_error_admin');
}
}else{
@include_once DISCUZ_ROOT.'./data/sysdata/cache_dzapp_haodai_city_sort.php';
}
if(!$_GET['city']){
include template('dzapp_haodai:city');
}else{
if(!$_GET['city'] || $_GET['formhash'] != FORMHASH || !$zones[$_GET['city']]) showmessage('dzapp_haodai:city_choose_wrong');
dsetcookie('HD_CITY', $_GET['city']);
showmessage('dzapp_haodai:city_choose_ok', 'plugin.php?id=dzapp_haodai');
}
?>