-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinit.php
127 lines (103 loc) · 4.04 KB
/
init.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
// disable PHP xdebug module
if(function_exists('xdebug_disable')) { xdebug_disable(); }
error_reporting(E_ALL ^ E_DEPRECATED);
// set 0 UTC timezone
date_default_timezone_set('UTC');
$gsValues = array();
include ('config.custom.php');
include ('config.php');
// strip server name slashes
$gsValues['NAME'] = stripcslashes($gsValues['NAME']);
// check for some variables
if (!isset($gsValues['CONNECTION_TIMEOUT']))
{
$gsValues['CONNECTION_TIMEOUT'] = '5';
}
if (!isset($gsValues['URL_LOGIN']))
{
$gsValues['URL_LOGIN'] = $gsValues['URL_ROOT'];
}
// check for last slash in root path
if (substr($gsValues['PATH_ROOT'], -1) != '/')
{
$gsValues['PATH_ROOT'] .= '/';
}
// prepare url to logo image
$gsValues['URL_LOGO'] = $gsValues['URL_ROOT'].'/img/logo.png';
// prepare language array
$la = array();
// gets language from cookies
if (isset($_COOKIE['gs_language']))
{
$gsValues['LANGUAGE'] = $_COOKIE['gs_language'];
}
else
{
$expire = time() + 2592000;
setcookie('gs_language', $gsValues['LANGUAGE'], $expire, '/');
}
// puts selected language into cookies
if (isset($_GET['lng']))
{
$gsValues['LANGUAGE'] = $_GET['lng'];
$expire = time() + 2592000;
setcookie('gs_language', $gsValues['LANGUAGE'], $expire, '/');
}
// connect to mysql
$ms = mysqli_connect($gsValues['DB_HOSTNAME'], $gsValues['DB_USERNAME'], $gsValues['DB_PASSWORD'], $gsValues['DB_NAME'], $gsValues['DB_PORT']);
if (!$ms)
{
echo "Error connecting to database.";
die;
}
mysqli_set_charset($ms, 'utf8');
$q = "SET SESSION sql_mode = ''";
$r = mysqli_query($ms, $q);
// security to avoid MySQL injection attacks
if(isset($_COOKIE))
{
foreach ($_COOKIE as $key => $value)
{
if(get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
if(!is_array($value))
{
$value = mysqli_real_escape_string($ms, $value);
}
$_COOKIE[$key] = $value;
}
}
if(isset($_POST))
{
foreach ($_POST as $key => $value)
{
if(get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
if(!is_array($value))
{
$value = mysqli_real_escape_string($ms, $value);
}
$_POST[$key] = $value;
}
}
if(isset($_GET))
{
foreach ($_GET as $key => $value)
{
if(get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
if(!is_array($value))
{
$value = mysqli_real_escape_string($ms, $value);
}
$_GET[$key] = $value;
}
}
?>