forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
function.php
69 lines (63 loc) · 1.85 KB
/
function.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
<?php
if (empty($config)) {
return true;
}
// filter some security here
if(!empty($_GET['lang'])){
$_GET['lang'] = str_replace(array("'",'"',""","'"), array('','','',''), xss_esc($_GET['lang']));
}
if (empty($_SESSION['language'])) {
$_SESSION['language'] = $config->getLanguage();
}
if (!empty($_GET['lang'])) {
$_GET['lang'] = strip_tags($_GET['lang']);
$_SESSION['language'] = $_GET['lang'];
}
@include_once "{$global['systemRootPath']}locale/{$_SESSION['language']}.php";
function __($str) {
global $t;
if (empty($t[$str])) {
return $str;
} else {
return $t[$str];
}
}
function getAllFlags() {
global $global;
$dir = "{$global['systemRootPath']}view/css/flag-icon-css-master/flags/4x3";
$flags = array();
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$flags[] = str_replace(".svg", "", $entry);
}
}
closedir($handle);
}
sort($flags);
return $flags;
}
function getEnabledLangs() {
global $global;
$dir = "{$global['systemRootPath']}locale";
$flags = array();
if (empty($global['dont_show_us_flag'])) {
$flags[] = 'us';
}
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && $entry != "index.php" && $entry != "function.php" && $entry != "save.php") {
$flags[] = str_replace(".php", "", $entry);
}
}
closedir($handle);
}
sort($flags);
return $flags;
}
function textToLink($string) {
return preg_replace(
"~[[:alpha:]]+://[^<>[:space:]'\"]+[[:alnum:]/]~", "<a href=\"\\0\">\\0</a>",
$string
);
}