-
Notifications
You must be signed in to change notification settings - Fork 26
/
init.php
38 lines (30 loc) · 1.08 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
<?php
require __DIR__ .'/config.php';
require __DIR__ .'/libs/common.php';
require __DIR__ .'/libs/AumWAF.class.php';
require __DIR__ .'/libs/smarty/Smarty.class.php';
$smarty = new Smarty;
$smarty->setTemplateDir(dirname(__FILE__) . '/templates/');
$smarty->setCompileDir(dirname(__FILE__) . '/templates_c/');
$smarty->assign('cfg', $_CONFIG);
$mysqli = new mysqli($_CONFIG['database']['host'], $_CONFIG['database']['user'], $_CONFIG['database']['pass'], $_CONFIG['database']['dbnm']);
if ($mysqli->connect_error) {
die('Connect Error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
}
function getUsernameById($id) {
global $mysqli;
return $mysqli->query("SELECT username FROM tbl_users WHERE id = " . $id)->fetch_object()->username;
}
function getIdByUsername($username) {
global $mysqli;
return $mysqli->query("SELECT id FROM tbl_users WHERE username = '" . $username . "'")->fetch_object()->id;
}
if (strlen(session_id()) < 1) {
session_start();
}
(new AumWAF)
->initialize()
->prepare($_GET, $_POST, $_COOKIE, $_SERVER, $_REQUEST)
->detect()
->block();