-
Notifications
You must be signed in to change notification settings - Fork 1
/
system.php
48 lines (43 loc) · 1.43 KB
/
system.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
<?php
session_start();
define("IN_SYSTEM",true);
date_default_timezone_set("Asia/Taipei");
require_once("config/default_config.php");
require_once("func/sql.php");
require_once("func/functions.php");
# template variables
$E = array();
$E["msg"] = "";
$E["locale"] = "en_US";
if (isset($_COOKIE["locale"]) && in_array($_COOKIE["locale"], $config["locale"])) {
$E["locale"] = $_COOKIE["locale"];
}
$uid = checklogin();
if($uid!==false){
$E["login"] = true;
$db = PDO_prepare("SELECT * FROM `table:account` WHERE `id`=:id");
$db->bindValue("id", $uid, PDO::PARAM_INT);
$db->execute();
$data = $db->fetchAll()[0];
$E["nick"] = $data["nickname"];
$E["acct"] = $data["account"];
if (in_array($data["locale"], $config["locale"])) {
$E["locale"] = $data["locale"];
}
}else {
$E["login"] = false;
}
if (isset($_GET["locale"]) && in_array($_GET["locale"], $config["locale"])) {
$E["locale"] = $_GET["locale"];
if ($E["login"] && $E["locale"] != $data["locale"]) {
$db = PDO_prepare("UPDATE `table:account` SET `locale`='".$E["locale"]."' WHERE `id`=:id");
$db->bindValue("id", $uid, PDO::PARAM_INT);
$db->execute();
}
}
putenv("LANG=".$E["locale"]);
setlocale(LC_ALL, $E["locale"].".utf8");
bind_textdomain_codeset("login", "UTF-8");
bindtextdomain("login", "locale");
textdomain("login");
setcookie("locale", $E["locale"], time()+60*60*24*30, parse_url($config["site"]["url"], PHP_URL_PATH), parse_url($config["site"]["url"], PHP_URL_HOST));