chengkun
2025-05-22 3b321a2882db082c68aaf8771e0f55daa58a63d3
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
<?php
 
 
 
if ($config['sy_web_site'] == '1' && !isset($_POST['xcxCode'])) {
 
    $protocol   =   getprotocol($config['sy_weburl']);
    $host       =   $protocol.$_SERVER['HTTP_HOST'];
 
    // 本地路径不做验证
    if (!strpos($host, 'localhost') && !strpos($host, '127.0.0.1')) {
 
        $indexDir   =   $_GET['indexdir'];
 
        //非目录形式 根据cookie信息验证
        if (!$indexDir) {
 
            if (isMobileUser()) {
                // 手机端存在二级域名
                if (!empty($config['sy_wapdomain']) && $config['sy_wapdomain'] == $_SERVER['HTTP_HOST']) {
                    $need1 = true;
                }
                // 手机端不存在二级域名,判断访问域名和主域名是否一致
                if (empty($config['sy_wapdomain']) && $config['sy_weburl'] == $host) {
                    $need2 = true;
                }
                // 两种情况存在一种,就要判断分站是否已经判断处理过了,防止重复判断
                if ($need1 || $need2) {
                    if (($_COOKIE['cityid'] || $_COOKIE['hyclass'] || $_COOKIE['three_cityid'] || $_COOKIE['province']) && $_COOKIE['did']) {
 
                        $isSiteInfo = 1;
                    }
                }
            } else {
 
                if (isset($_COOKIE['sy_weburl']) && $_COOKIE['sy_weburl'] == $host) {
 
                    $isSiteInfo = 1;
                }
            }
        }
 
        if (!$isSiteInfo) {
            include(PLUS_PATH . "/domain_cache.php");
            if (is_array($site_domain)) {
                foreach ($site_domain as $key => $value) {
                    if (($value['host'] == $_SERVER['HTTP_HOST'] && $value['mode'] != '2') || ($indexDir != '' && $value['indexdir'] == $indexDir && $value['mode'] == '2')) {
                        $value['did'] = $value['id'];
                        $value['sy_webname'] = $value['webname'];
                        $value['sy_webtitle'] = $value['webtitle'];
                        $value['sy_logo'] = $value['weblogo'];
                        $value['sy_webkeyword'] = $value['webkeyword'];
                        $value['sy_webmeta'] = $value['webmeta'];
 
                        $domainInfo = $value;
 
                        break;
                    }
                }
            }
 
            setcookies(
                array(
                    'sy_weburl' => '',
                    'did' => '',
                    'fz_type' => '',
                    'province' => '',
                    'cityid' => '',
                    'hyclass' => '',
                    'three_cityid' => '',
                    'cityname' => '',
                    'sy_webkeyword' => '',
                    'sy_logo' => '',
                    'style' => '',
                    'sy_webtitle' => '',
                    'sy_webmeta' => '',
                    'sy_webname' => ''
                ), time() - 86400, $domainUrl);
        } else {
 
            $domainInfo = $_COOKIE;
 
        }
        if ($indexDir && $domainInfo['indexdir'] != $indexDir) {
            Header("HTTP/1.1 404 Not Found");
            exit();
 
        }
        if ($domainInfo) {
 
 
            include(PLUS_PATH . "/city.cache.php");
            include(PLUS_PATH . "/industry.cache.php");
 
            $parseDate['did'] = (int)$domainInfo['did'];
            $parseDate['fz_type'] = (int)$domainInfo['fz_type'];
            if ($parseDate['fz_type'] == '1') {
 
                if ($domainInfo['three_cityid'] > 0) {
                    $parseDate['province'] = (int)$domainInfo['province'];
                    $parseDate['cityid'] = (int)$domainInfo['cityid'];
                    $parseDate['three_cityid'] = (int)$domainInfo['three_cityid'];
                    $parseDate['cityname'] = $city_name[$domainInfo['three_cityid']];
                } elseif ($domainInfo['cityid'] > 0) {
                    $parseDate['province'] = (int)$domainInfo['province'];
                    $parseDate['cityid'] = (int)$domainInfo['cityid'];
                    $parseDate['three_cityid'] = 0;
                    $parseDate['cityname'] = $city_name[$domainInfo['cityid']];
                } else {
                    $parseDate['province'] = (int)$domainInfo['province'];
                    $parseDate['cityid'] = 0;
                    $parseDate['three_cityid'] = 0;
                    $parseDate['cityname'] = $city_name[$domainInfo['province']];
                }
            } else if ($parseDate['fz_type'] == '2' && ($domainInfo['hy'] || $domainInfo['hyclass'])) {
                $parseDate['hyclass'] = (int)$domainInfo['hy'] ? (int)$domainInfo['hy'] : (int)$domainInfo['hyclass'];
                $parseDate['cityname'] = $domainInfo['sy_webname'];
 
            }
 
            if ($domainInfo['sy_webname']) {
                $parseDate['sy_webname'] = $domainInfo['sy_webname'];
            }
            if ($domainInfo['sy_webtitle']) {
                $parseDate['sy_webtitle'] = $domainInfo['sy_webtitle'];
            }
            if ($domainInfo['sy_logo']) {
                $parseDate['sy_logo'] = $domainInfo['sy_logo'];
            }
            if ($domainInfo['sy_webkeyword']) {
                $parseDate['sy_webkeyword'] = $domainInfo['sy_webkeyword'];
            }
            if ($domainInfo['sy_webmeta']) {
                $parseDate['sy_webmeta'] = $domainInfo['sy_webmeta'];
            }
            if ($domainInfo['style']) {
                $parseDate['style'] = $domainInfo['style'];
            }
            if (!$indexDir) {
                if (isMobileUser()) {
                    // 手机端使用主站域名
                    $parseDate['sy_weburl'] = $config['sy_weburl'];
 
                } else {
                    // pc端直接使用访问域名
                    $parseDate['sy_weburl'] = $host;
                }
            }
 
            $config = array_merge($config, $parseDate);
 
            if (!$indexDir) {
                if (strpos($host, $config['sy_onedomain']) !== false) {
                    $domainUrl = $config['sy_onedomain'];
                } else {
                    $domainUrlAll = parse_url($host);
                    $domainUrl = get_domain($domainUrlAll['host']);
                }
 
                setcookies($parseDate, time() + 86400, $domainUrl);
            }
        }
    }
}
 
?>