chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
 
class site_controller extends common{
    function index_action(){
        if($this->config["sy_web_site"]!="1"){
            $this->ACT_msg_wap($_SERVER['HTTP_REFERER'], $msg = "暂未开启多站点模式!",2,5);
        }
        
        $this->yunset("headertitle","分站");
        $this->seo("index");
        $this->yuntpl(array('wap/site'));
    }
    function cache_action(){
        global $db,$db_config;
        include(PLUS_PATH."domain_cache.php");
        include(PLUS_PATH."config.php");
        
        $domainarr = array();
        $hy_site = array();
        foreach($site_domain as $k=>$v){
            if($v['fz_type']=='1'){
                if($v['three_cityid']>0){
                    $cityid=$v['three_cityid'];
                }elseif($v['cityid']>0){
                    $cityid=$v['cityid'];
                }else{
                    $cityid=$v['province'];
                }
                
                if($v['mode']=='2'){
                    $indexdir[$cityid] = $v['indexdir'];
                    $domainarr[$cityid]=$config['sy_weburl'].'/'.$v['indexdir'].'/';
                }else{
                    $domainarr[$cityid]='http://'.$v['host'];
                }
                
                $city_id[]=$cityid;
            }elseif($v['fz_type']=='2'){
                
                if($v['mode']=='2'){
                    $v['url']=$config['sy_weburl'].'/'.$v['indexdir'].'/';
                }else{
                    $v['url']='http://'.$v['host'];
                }
                $hy_site[]=$v;
            } 
        }
        $city_ids=implode(",",$city_id);
        $sitecity=$db->select_all("city_class","`id` in(".$city_ids.")","`id`,`name`,`letter`");
        $city_ABC = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
        foreach($city_ABC as $key=>$val){
            foreach($sitecity as $v){
                if($val==$v['letter']){
                    $v['indexdir']=$indexdir[$v['id']];
                    $v['url']=$domainarr[$v['id']];
                    $site[$val][] = $v;
                }
            }
        }
        $return['city'] = $site;
        $return['hy'] = $hy_site;
        echo json_encode($return);
    }
    
  function domain_action(){
        $id=(int)$_GET['id']; 
        include(PLUS_PATH."domain_cache.php");
        include(PLUS_PATH."city.cache.php");
        $host =  $this->protocol.$_SERVER['HTTP_HOST']; 
        if(strpos($host,$this->config['sy_onedomain'])!==false){
            $domainUrl  = $this->config['sy_onedomain'];
        }else{
            $domainUrlAll  = parse_url($host);
            $domainUrl = $domainUrlAll['host'];
        } 
        
        if($id>=1){ 
            $domain=array();  
            foreach($site_domain as $key=>$val){
                if($val['fz_type']==1){
                    // 从最高级开始匹配,匹配到,循环就不再执行
                    if ($val['province']==$id){
                        $domain = $val;
                        break;
                    }elseif ($val['cityid']==$id){
                        $domain = $val;
                        break;
                    }elseif($val['three_cityid']==$id){
                        $domain = $val;
                    }
                    
                }elseif ($val['fz_type']==2 && $val['id']==$id){
                    $domain=$val;
                }
            }
            
            if($domain){
                $parseDate['did']=$domain['id'];
                $parseDate['fz_type']=$domain['fz_type'];
                if($parseDate['fz_type']=='1'){
                    if($domain['three_cityid']>0){
                        $parseDate['province']        =    $domain['province'];
                        $parseDate['cityid']        =    $domain['cityid'];
                        $parseDate['three_cityid']    =    $domain['three_cityid'];
                        $parseDate['cityname']        =    $city_name[$domain['three_cityid']];
                    }elseif($domain['cityid']>0){
                        $parseDate['province']        =    $domain['province'];
                        $parseDate['cityid']        =    $domain['cityid'];
                        $parseDate['three_cityid']    =    0;
                        $parseDate['cityname']        =    $city_name[$domain['cityid']];
                    }elseif($domain['province']){
                        $parseDate['province']        =    $domain['province'];
                        $parseDate['cityid']        =    0;
                        $parseDate['three_cityid']    =    0;
                        $parseDate['cityname']        =    $city_name[$domain['province']];
                    }
                    setcookies('hyclass',time()-86400,$this->config['sy_onedomain']);
                }else if($parseDate['fz_type']=='2'&&$domain['hy']){
                    $parseDate['hyclass']       =   $domain['hy'];
                    $parseDate['cityname']        =    $domain['webname'];
                    setcookies(
                        array(
                        'province'=>'',
                        'cityid'=>'',
                        'three_cityid'=>''
                        ),time()-86400,"/"
                    );
                }    
                if($domain['webname']){$parseDate['sy_webname']  =    $domain['webname'];}
                if($domain['webtitle']){$parseDate['sy_webtitle']  =    $domain['webtitle'];}
                if($domain['weblogo']){$parseDate['sy_logo']  =    $domain['weblogo'];}
                if($domain['webkeyword']){$parseDate['sy_webkeyword']  =    $domain['webkeyword'];}
                if($domain['webmeta']){$parseDate['sy_webmeta']  =    $domain['webmeta'];}
                if($domain['style']){$parseDate['style']  =    $domain['style'];}  
                $parseDate['sy_wapurl']  =    $host.'/wap';
                
                
                 
                $this->config = array_merge($this->config,$parseDate); 
                
                foreach($parseDate as $key=>$value){
                    $this->cookie->SetCookie($key,$value,time()+86400);
                }
            }
        }
            
        if(!$parseDate){
            setcookies(
                array(
                'sy_wapurl'=>'',
                'did'=>'',
                'fz_type'=>'',
                'province'=>'',
                'cityid'=>'',
                'hyclass'=>'',
                'three_cityid'=>'',
                'cityname'=>'',
                'sy_webkeyword'=>'', 
                'sy_logo'=>'',
                'style'=>'',
                'sy_webtitle'=>'',
                'sy_webmeta'=>'',
                'sy_webname'=>''
 
            ),time()-86400,$domainUrl);
        
        }
        header("location:".$this->config['sy_wapdomain'].'/');die;
    }
}
?>