-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
113 lines (106 loc) · 4.84 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
$configFile = fopen("config.json", "r") or die("Unable to open config.json file");
$configJson = fread($configFile, filesize("config.json"));
fclose($configFile);
$config = json_decode($configJson, true);
$langCode = null;
$acceptLang = [];
if(in_array('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
$langCode = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
foreach (scandir("localization") as $langFile) {
if ($langFile != "." && $langFile != "..") {
$acceptLang[] = pathinfo($langFile, PATHINFO_FILENAME);
}
}
}
$langCode = in_array($langCode, $acceptLang) ? $langCode : 'en';
$langCodeFilename = "localization/$langCode.json";
$langCodeFile = fopen($langCodeFilename, "r") or die("Unable to open localization/$langCode.json file");
$langCodeJson = fread($langCodeFile, filesize($langCodeFilename));
fclose($langCodeFile);
$lang = json_decode($langCodeJson, true);
function tr($key) {
echo $GLOBALS['lang'][$key] ?? $key;
}
?>
<!DOCTYPE html>
<html lang="<?php echo $langCode; ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title><?php tr("SITE_TITLE") ?></title>
<meta name="description" content="<?php tr("SITE_DESCRIPTION") ?>">
<link rel="stylesheet" href="dist/style.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,700" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link rel="shortcut icon" href="dist/images/favicon.ico" />
</head>
<body class="Wrapper">
<div class="Sheet">
<div class="Title">
<a href="https://wikitolearn.org" class="Title__content">
<img class="Title__logo" src="dist/images/wikitolearn-logo.png" alt="wikitolearn logo">
<img class="Title__name" src="dist/images/name.svg" alt="wikitolearn chat logo">
<span class="Title__text">Chat</span>
</a>
</div>
<main class="Content">
<div class="Content__description">
<?php tr("SITE_MESSAGE") ?>
</div>
<br>
<div class="Content__description">
<?php tr("CHAT_DESCRIPTION") ?>
</div>
<div class="Content__chats Chats">
<?php
$chats = $config["chats"];
foreach ($chats as $chat) {
?>
<a href="<?php echo $chat["href"]; ?>" class="Chat__link">
<div class="Chat">
<div class="Chat__meta">
<div class="Chat__title"><?php tr("CHAT_" . $chat["key"] . "_TITLE"); ?></div>
<div class="Chat__description"><?php tr("CHAT_" . $chat["key"] . "_DESCRIPTION"); ?></div>
</div>
<div class="Chat__control">
<i class="<?php echo $chat["icon"]; ?>"></i>
<span class="Chat__control-text"><?php tr("CHAT_" . $chat["key"] . "_ACTION"); ?></span>
</div>
</div>
</a>
<?php
}
?>
</div>
<div class="Content__description">
<?php tr("OTHER_DESCRIPTION") ?>
</div>
<div class="Content__chats Chats">
<?php
$others = $config["others"];
foreach ($others as $other) {
?>
<a href="<?php echo $other["href"]; ?>" class="Chat__link">
<div class="Chat">
<div class="Chat__meta">
<div class="Chat__title"><?php tr("OTHER_" . $other["key"] . "_TITLE"); ?></div>
<div class="Chat__description"><?php tr("OTHER_" . $other["key"] . "_DESCRIPTION"); ?></div>
</div>
<div class="Chat__control">
<i class="<?php echo $other["icon"]; ?>"></i>
<span class="Chat__control-text"><?php tr("OTHER_" . $other["key"] . "_ACTION"); ?></span>
</div>
</div>
</a>
<?php
}
?>
</div>
</main>
</div>
<div class="Footer">
</div>
</body>
</html>