-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.php
More file actions
55 lines (40 loc) · 1.33 KB
/
config.php
File metadata and controls
55 lines (40 loc) · 1.33 KB
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
<?php
session_start();
define('ROOT_DIR', dirname(__FILE__).'/');
// define('DATABASE_HOST','127.0.0.1');
// define('DATABASE_USER','*******************');
// define('DATABASE_PASSWORD','*******************');
// define('DATABASE_NAME','*******************');
@include_once ROOT_DIR . 'password.php';
// @require_once ROOT_DIR . 'waf.php';
function relative($file)
{
if (defined('RELATIVE_PATH')) {
return RELATIVE_PATH;
}
$relative_path = '';
$absolute_path = str_replace(ROOT_DIR, '', dirname($file).'/');
$str_length = strlen($absolute_path);
for ($i = 0; $i < $str_length; $i++) {
if ($absolute_path[$i] == '/') {
$relative_path = $relative_path . '../';
}
}
if ($relative_path == '') {
$relative_path = './';
}
define('RELATIVE_PATH', $relative_path);
return RELATIVE_PATH;
}
function get_sql_conn(){
$conn = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_NAME);
if (!$conn) {
header('HTTP/1.1 500 Internal Server Error');
die("Failed to connect to database");
}
if(mysqli_set_charset($conn,"utf8") == false){
header('HTTP/1.1 500 Internal Server Error');
die("An error occurred while modifying the database connection character set to utf8");
}
return $conn;
}