|
@@ -1,22 +1,25 @@
|
1
|
1
|
<?php
|
2
|
2
|
include "config.php";
|
3
|
3
|
|
4
|
|
-$table = str_replace('*','%',preg_replace('/[^a-zA-Z0-9\-_*]/','',isset($_GET["table"])?$_GET["table"]:'*'));
|
|
4
|
+$table = str_replace('*','%',preg_replace('/[^a-zA-Z0-9\-_*\/]/','',isset($_GET["table"])?$_GET["table"]:'*'));
|
5
|
5
|
$callback = preg_replace('/[^a-zA-Z0-9\-_]/','',isset($_GET["callback"])?$_GET["callback"]:false);
|
6
|
6
|
|
7
|
7
|
$mysqli = new mysqli($config["hostname"], $config["username"], $config["password"], $config["database"]);
|
8
|
8
|
|
9
|
9
|
if ($mysqli->connect_errno) die('Connect failed: '.$mysqli->connect_error);
|
10
|
10
|
|
|
11
|
+$tablelist = explode('/',$table);
|
11
|
12
|
$tables = array();
|
12
|
13
|
|
13
|
|
-if ($result = $mysqli->query("SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME` LIKE '$table' AND `TABLE_SCHEMA` = '$config[database]'")) {
|
14
|
|
- while ($row = $result->fetch_row()) $tables[] = $row[0];
|
15
|
|
- $result->close();
|
|
14
|
+foreach ($tablelist as $table) {
|
|
15
|
+ if ($result = $mysqli->query("SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME` LIKE '$table' AND `TABLE_SCHEMA` = '$config[database]'")) {
|
|
16
|
+ while ($row = $result->fetch_row()) $tables[] = $row[0];
|
|
17
|
+ $result->close();
|
|
18
|
+ }
|
16
|
19
|
}
|
17
|
20
|
|
18
|
|
-if ($config["whitelist"]) $tables = array_intersect($tables, $config["whitelist"]);
|
19
|
|
-if ($config["blacklist"]) $tables = array_diff($tables, $config["blacklist"]);
|
|
21
|
+if ($config["read_whitelist"]) $tables = array_intersect($tables, $config["read_whitelist"]);
|
|
22
|
+if ($config["read_blacklist"]) $tables = array_diff($tables, $config["read_blacklist"]);
|
20
|
23
|
|
21
|
24
|
if (empty($tables)) {
|
22
|
25
|
die(header("Content-Type:",true,404));
|