This commit is contained in:
szabomarton 2025-02-12 07:49:03 +01:00
parent 81f7f2d79b
commit 5b582005f1
2 changed files with 14 additions and 5 deletions

View File

@ -7,7 +7,7 @@
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
</head> </head>
<body> <body>
<form action="asd.php" method="POST"> <form action="results.php" method="POST">
<label>felhasználó neve: </label> <label>felhasználó neve: </label>
<input type="text" name="user"> <input type="text" name="user">
<button type="submit">Felhasználó adatainak megjelenítése</button> <button type="submit">Felhasználó adatainak megjelenítése</button>

View File

@ -3,21 +3,30 @@ require_once('config.php');
function parseGrant($grant) { function parseGrant($grant) {
if (preg_match("/GRANT (.*?) ON `(.*?)`\.`(.*?)`(?: \((.*?)\))?/", $grant, $matches)) { if (preg_match("/GRANT (.*?) ON `(.*?)`\.`(.*?)`(?: \((.*?)\))?/", $grant, $matches)) {
$permissions = preg_replace("/\(.*?\)/", "", $matches[1]); $permissions = trim($matches[1]);
// Új elágazás az oszlopok kezelésére
if (preg_match("/(\w+) \((.*?)\)/", $permissions, $permMatches)) {
$permissions = trim($permMatches[1]);
$columns = array_map('htmlspecialchars', array_map('trim', explode(',', $permMatches[2])));
} else {
$columns = ["*"];
}
$database = htmlspecialchars($matches[2]); $database = htmlspecialchars($matches[2]);
$table = htmlspecialchars($matches[3]); $table = htmlspecialchars($matches[3]);
$columns = !empty($matches[4]) ? array_map('htmlspecialchars', array_map('trim', explode(',', $matches[4]))) : ["-"];
return [$permissions, $database, $table, $columns]; return [$permissions, $database, $table, $columns];
} elseif (preg_match("/GRANT (.*?) ON `(.*?)`\.\*/", $grant, $matches)) { } elseif (preg_match("/GRANT (.*?) ON `(.*?)`\.\*/", $grant, $matches)) {
$permissions = preg_replace("/\(.*?\)/", "", $matches[1]); $permissions = trim($matches[1]);
$database = htmlspecialchars($matches[2]); $database = htmlspecialchars($matches[2]);
return [$permissions, $database, "Minden tábla", ["-"]]; return [$permissions, $database, "Minden tábla", ["Minden oszlop"]];
} }
return ["Ismeretlen", "-", "-", ["-"]]; return ["Ismeretlen", "-", "-", ["-"]];
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">