TODO finish this shit
This commit is contained in:
parent
2e23bb4cd5
commit
e100654e77
|
@ -1,5 +1,23 @@
|
|||
<?php
|
||||
require_once('config.php');
|
||||
|
||||
function parseGrant($grant) {
|
||||
if (preg_match("/GRANT (.*?) ON `(.*?)`\.`(.*?)`(?: \((.*?)\))?/", $grant, $matches)) {
|
||||
$permissions = preg_replace("/\(.*?\)/", "", $matches[1]);
|
||||
$database = htmlspecialchars($matches[2]);
|
||||
$table = htmlspecialchars($matches[3]);
|
||||
$columns = !empty($matches[4]) ? array_map('htmlspecialchars', array_map('trim', explode(',', $matches[4]))) : ["-"];
|
||||
return [$permissions, $database, $table, $columns];
|
||||
} elseif (preg_match("/GRANT (.*?) ON `(.*?)`\.\*/", $grant, $matches)) {
|
||||
$permissions = preg_replace("/\(.*?\)/", "", $matches[1]);
|
||||
$database = htmlspecialchars($matches[2]);
|
||||
return [$permissions, $database, "Minden tábla", ["-"]];
|
||||
}
|
||||
return ["Ismeretlen", "-", "-", ["-"]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
@ -24,15 +42,30 @@ require_once('config.php');
|
|||
$result = $conn->query($sql);
|
||||
|
||||
if ($result) {
|
||||
// Bejárjuk az eredményhalmazt
|
||||
echo "<table border='1'>";
|
||||
echo "<tr><th>Felhasználó</th><th>Jogosultság</th><th>Adatbázis</th><th>Tábla</th><th>Oszlop</th></tr>";
|
||||
|
||||
while ($row = $result->fetch_array(MYSQLI_NUM)) {
|
||||
foreach ($row as $grant) {
|
||||
echo $grant . "<br>";
|
||||
list($permissions, $database, $table, $columns) = parseGrant($grant);
|
||||
echo "<tr>";
|
||||
echo "<td>" . htmlspecialchars($_POST["user"]) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($permissions) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($database) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($table) . "</td>";
|
||||
echo "<td>" . htmlspecialchars(implode(", ", $columns)) . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "Hiba a lekérdezésben: " . $conn->error;
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user