-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
91 lines (82 loc) · 2.25 KB
/
index.php
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
<?php
$title = [
];
$lang = [
'en' => [
'title' => 'This domain is for sale.',
'description' => '',
'contactUs' => 'contact us',
],
'zh' => [
'title' => '该域名出售!',
'description' => '',
'contactUs' => '联系我们',
],
];
$view['lang'] = getBrowserLanguage();
$view['currentDomain'] = getDomain();
$view['title'] = $view['currentDomain'] . $lang[$view['lang']]['title'];
$view['contactUs'] = $lang[$view['lang']]['contactUs'];
$view['mail'] = '[email protected]';
//var_dump($view);
function getDomain()
{
if(strpos($_SERVER["HTTP_HOST"],':')){
$domain=substr($_SERVER["HTTP_HOST"],0,strpos($_SERVER["HTTP_HOST"],':'));
}else{
$domain=$_SERVER["HTTP_HOST"];
}
if(substr($domain,0,4)=='www.'){
$domain=substr($domain,4,strlen($domain));
}
return $domain;
}
function getBrowserLanguage()
{
foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) {
$pattern = '/^(?P<primarytag>[a-zA-Z]{2,8})' .
'(?:-(?P<subtag>[a-zA-Z]{2,8}))?(?:(?:;q=)' .
'(?P<quantifier>\d\.\d))?$/';
$splits = array();
//printf("Lang:,,%s''\n", $lang);
if (preg_match($pattern, $lang, $splits)) {
// print_r($splits);
return $splits[1];
}
}
return 'en'; //默认
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title><?= $view['title'] ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<style type="text/css">
body {
color: #222;
font-family: arial, helvetica, sans-serif;
background: #dfdfdf;
}
.center {
height: 250px;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: auto;
text-align: center;
}
</style>
<body>
<div id="content">
<div class="center">
<h1><?= $view['title'] ?></h1>
<p><strong></strong></p>
<p><?= $view['contactUs'] ?> :<a href="mailto:<?= $view['mail'] ?>" target="_blank"><?= $view['mail'] ?></a></p>
</div>
</div>
</body>
</html>