forked from yuantuo666/baiduwp-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
usersettings.php
141 lines (133 loc) · 5.36 KB
/
usersettings.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
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
<?php
/**
* PanDownload 网页复刻版,PHP 语言版用户设置文件
*
* 用户可在此设置
*
* @author Yuan_Tuo <[email protected]>
* @link https://imwcr.cn/
* @link https://space.bilibili.com/88197958
*
*/
if (!defined('init')) { // 直接访问处理程序
header('Content-Type: text/plain; charset=utf-8');
if (!file_exists('config.php')) {
http_response_code(503);
header('Content-Type: text/plain; charset=utf-8');
header('Refresh: 5;url=install.php');
die("HTTP 503 服务不可用!\r\n暂未安装此程序!\r\n将在五秒内跳转到安装程序!");
} else {
require('config.php');
}
http_response_code(403);
header('Refresh: 3;url=./');
define('init', true);
require('config.php');
die("HTTP 403 禁止访问!\r\n此文件是 PanDownload 网页复刻版 PHP 语言版项目的有关文件!\r\n禁止直接访问!");
}
?>
<style>
.card {
margin-top: 3rem;
}
#Browser-ColorMode,
#Browser-Language {
margin-right: 2rem;
}
.SaveTime {
margin-right: 0.8rem;
}
.card-item:not(:first-of-type) {
margin-top: 2rem;
}
select {
margin-top: 0.5rem;
}
</style>
<div class="card">
<div class="card-header"><?php echo Language["UserSettings"]; ?></div>
<div class="card-body">
<div class="card-item">
<h3><?php echo Language["ColorMode"]; ?></h3>
<div id="ColorMode-Setting-View">
<span class="SaveTime"><?php echo Language["SaveForever"]; ?></span>
<span><?php echo Language["BrowserSettings"]; ?></span><span id="Browser-ColorMode"></span>
<span><?php echo Language["CurrentSetting"]; ?></span><span id="Setting-ColorMode"></span>
</div>
<select id="ColorMode-Select" class="form-control">
<option value="auto"><?php echo Language["FollowBrowser"]; ?></option>
<option value="dark"><?php echo Language["DarkMode"]; ?></option>
<option value="light"><?php echo Language["LightMode"]; ?></option>
</select>
</div>
<div class="card-item">
<h3><?php echo Language["LanguageChoose"]; ?></h3>
<div id="LanguageChoose">
<span class="SaveTime"><?php echo Language["Save365"]; ?></span>
<span><?php echo Language["BrowserSettings"]; ?></span><span id="Browser-Language"><?php echo BrowserLanguage; ?></span>
<span><?php echo Language["CurrentDisplayed"]; ?></span><span id="Displayed-Language"><?php echo Lang; ?></span>
</div>
<select id="Language-Select" class="form-control">
<option value="auto"><?php echo Language["FollowBrowser"]; ?></option>
<option value="zh-CN">简体中文</option>
<option value="en">English</option>
</select>
</div>
</div>
</div>
<script>
if (localStorage.getItem('colorMode') === null) { // 判断用户设置的颜色
$('#Setting-ColorMode').text('<?php echo Language["FollowBrowser"]; ?>'); // 跟随浏览器
$('#ColorMode-Select option[value=auto]')[0].selected = true;
} else if (localStorage.getItem('colorMode') === 'dark') { // 深色模式
$('#Setting-ColorMode').text('<?php echo Language["DarkMode"]; ?>');
$('#ColorMode-Select option[value=dark]')[0].selected = true;
} else if (localStorage.getItem('colorMode') === 'light') { // 浅色模式
$('#Setting-ColorMode').text('<?php echo Language["LightMode"]; ?>');
$('#ColorMode-Select option[value=light]')[0].selected = true;
}
const LanguageSetting = '<?php echo $_COOKIE['Language']; ?>';
if (LanguageSetting === '') { // 判断用户设置的语言
$('#Language-Select option[value=auto]').text('<?php echo Language["CurrentSetting"]; ?>' + $('#Language-Select option[value=auto]').text());
$('#Language-Select option[value=auto]')[0].selected = true;
} else if (LanguageSetting === 'zh-CN') { // zh-CN
$('#Language-Select option[value="zh-CN"]').text('<?php echo Language["CurrentSetting"]; ?>' + $('#Language-Select option[value="zh-CN"]').text());
$('#Language-Select option[value="zh-CN"]')[0].selected = true;
} else if (LanguageSetting === 'en') { // en
$('#Language-Select option[value="en"]').text('<?php echo Language["CurrentSetting"]; ?>' + $('#Language-Select option[value="en"]').text());
$('#Language-Select option[value="en"]')[0].selected = true;
}
if (window.matchMedia('(prefers-color-scheme: dark)').matches) { // 获取浏览器设置
$('#Browser-ColorMode').text('<?php echo Language["DarkMode"]; ?>'); // 深色模式
} else if (window.matchMedia('(prefers-color-scheme: light)').matches) {
$('#Browser-ColorMode').text('<?php echo Language["LightMode"]; ?>'); // 浅色模式
}
window.matchMedia('(prefers-color-scheme: dark)').addListener(function(e) { // 当色彩模式改变为深色模式
if (e.matches) {
$('#Browser-ColorMode').text('<?php echo Language["DarkMode"]; ?>');
}
});
window.matchMedia('(prefers-color-scheme: light)').addListener(function(e) { // 当色彩模式改变为浅色模式
if (e.matches) {
$('#Browser-ColorMode').text('<?php echo Language["LightMode"]; ?>');
}
});
$('#ColorMode-Select').on('change', function() {
if (this.value === 'auto') {
localStorage.removeItem('colorMode');
location.reload();
} else {
localStorage.setItem('colorMode', this.value);
location.reload();
}
});
$('#Language-Select').on('change', function() {
if (this.value === 'auto') {
document.cookie = 'Language=; expires=Thu, 01 Jan 1970 00:00:00 GMT';
location.reload();
} else {
document.cookie = `Language=${this.value}; expires=${new Date(Date.now() + 31536000000)}`;
location.reload();
}
});
</script>