-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirs.php
executable file
·46 lines (43 loc) · 1.66 KB
/
dirs.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
<?php
ini_set("display_errors","true");
session_start();
function checkperm($type="") {
global $user_id;
if(!$_SESSION["user_id"]) {echo json_encode(array("relogin"=>true)); exit;}
else $user_id=$_SESSION["user_id"];
if($type and !$_SESSION["perms"][$type][$_SESSION["project_id"]] and !$_SESSION["perms"][$type][0]) { echo json_encode(array("template"=>_("You don't have access here"))); exit;}
}
if(!$relative) $relative="./";
$templatesdir=$relative."templates/";
$frontenddir=$relative."frontend/";
$shareddir=$relative."shared/";
$backenddir=$relative."backend/";
$jsdir=$relative."js/";
$secretdir=$relative."secrets/";#/var/www/opencodingsecrets/";
if($_GET["setlang"]) $_SESSION["locale"]=$_GET["setlang"];
if(!$_SESSION["locale"]) {
$accept=explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$keyaccept=array();
foreach($accept as $la) {
$tmp=explode(";q=",$la);
$keyaccept[$tmp[0]]=($tmp[1]?$tmp[1]:1);
}
$langs=array("en"=>"en_US","us"=>"en_US","au"=>"en_US","sg"=>"en_US","hk"=>"en_US","nz"=>"en_US","da"=>"da_DK","en_US"=>"en_US","da_DK"=>"da_DK");
$preferred=key(array_intersect_key($keyaccept,$langs));
if(!$preferred) $preferred="en";
$_SESSION["locale"]=$langs[$preferred];
}
$locale=$_SESSION["locale"];
if(function_exists("bindtextdomain")) {
putenv("LANGUAGE=".$locale.".UTF-8");
setlocale(LC_ALL,$locale.".UTF-8",$locale);
$domain="messages";
$pathToDomain = __DIR__ . "/locale";
$realpath=bindtextdomain($domain, $pathToDomain);
bind_textdomain_codeset($domain,"UTF-8");
} else { # If gettext doesn't work...
function _($s) {return $s;};
}
$results = textdomain($domain);
$lang=explode("_",$locale)[0];
$dateformat=array("en"=>"Y/m/d","da"=>"d-m-Y")[$lang];