forked from iqqmuT/toe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.php
53 lines (45 loc) · 1.39 KB
/
settings.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
<?php
/*
* Copyright 2012 Arno Teigseth, Tuomas Jaakola
*
* This file is part of TOE.
*
* TOE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TOE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TOE. If not, see <http://www.gnu.org/licenses/>.
*
* settings.php
*
* Returns JSON object.
*/
$data = array();
$data['changed'] = false;
$old_lang = $_GET['language_old'];
$new_lang = $_GET['language_new'];
if (strcmp($old_lang, $new_lang)) {
// language setting changed
$data['changed'] = true;
$data['redirect_url'] = "?lang=" . $new_lang;
}
// save language setting even though it was not changed
save_setting("lang", $new_lang);
// print response as JSON object
print json_encode($data);
// functions
// ---------
// save setting to a cookie
function save_setting($key, $value) {
// set cookie epxire time to be expired on 2 year
$expire = time() + (60 * 60 * 24 * 365 * 2);
setcookie($key, $value, $expire);
}
?>