-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
95 lines (71 loc) · 2.28 KB
/
index.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
<?php
header('Content-Type: text/html; charset=utf-8');
session_start();
define('BASE', dirname(__FILE__));
include './inc/functions.php';
if (!get($_SESSION, 'login') && !get($_SESSION, 'password')) {
if (get($_POST, 'login')) {
if (mysqli_connect('127.0.0.1', get($_POST, 'login'), get($_POST, 'password'))) {
$_SESSION['login'] = get($_POST, 'login');
$_SESSION['password'] = get($_POST, 'password');
header('Location:' . $_SERVER['REQUEST_URI']);
}
}
include './tpl/form.login.php';
die;
}
include './db/inc.php';
$requri = explode('?', trim($_SERVER['REQUEST_URI'], '/\\ '))[0];
$_GET['func'] = [];
if (strpos($requri, ':') !== false) {
$requri_arr_f = explode(':', $requri);
foreach ($requri_arr_f as $fnc) {
$pm = preg_match("/[\w]+\((.*?)\)/", $fnc);
// var_dump($pm);
if ($pm) {
$fname = explode('(', $fnc)[0];
$fargs = explode(',', explode('(', substr($fnc, 0, -1))[1]);
if (sizeof($fargs) == 1) {
$_GET['func'][$fname] = $fargs[0];
} else {
$_GET['func'][$fname] = $fargs;
}
}
}
}
$requri_arr = array_filter(
explode('/', explode(':', $requri)[0]
)
);
if (sizeof($requri_arr) > 1) {
$_GET['db'] = $requri_arr[0];
}
$sql = get($_GET, 'sql');
$db = get($_GET, 'db');
if ($sql && get($_GET['func'], 'system') !== 'sql') {
// die;
if ($db) {
header("Location: /$db/:system(sql)?sql=" . $sql);
} else {
header("Location: /:system(sql)?sql=" . $sql);
}
}
if (get($_GET['func'], 'system')) {
if (sizeof($requri_arr) > 1) {
$_GET['db'] = $requri_arr[0];
sql::_()->query('USE `' . $requri_arr[0] . '`');
}
$sfile = './pages/system/' . join('.', (array) get($_GET['func'], 'system')) . '.php';
include $sfile;
} else if (sizeof($requri_arr) == 1) {
$_GET['db'] = $requri_arr[0];
sql::_()->query('USE `' . $requri_arr[0] . '`');
include './pages/tables.php';
} else if (sizeof($requri_arr) == 2) {
$_GET['db'] = $requri_arr[0];
$_GET['table'] = $requri_arr[1];
sql::_()->query('USE `' . $requri_arr[0] . '`');
include './pages/table_data.php';
} else {
include './pages/databases.php';
}