71 lines
2.0 KiB
PHP
71 lines
2.0 KiB
PHP
<!DOCTYPE html>
|
|
|
|
|
|
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>GPO Query</title>
|
|
<link rel="stylesheet" href="styles.css">
|
|
</head>
|
|
<body>
|
|
<h2>Query GPOs by Group</h2>
|
|
<?php if (isset($_GET['group'])) : ?>
|
|
<form action="index.php" method="GET">
|
|
<label for="group">Group Name:</label>
|
|
<input type="text" id="group" name="group" value="<?php echo htmlspecialchars($_GET['group']); ?>" required>
|
|
<button type="submit">Query</button>
|
|
</form><p>
|
|
<?php else : ?>
|
|
<form action="index.php" method="GET">
|
|
<label for="group">Group Name:</label>
|
|
<input type="text" id="group" name="group" required>
|
|
<button type="submit">Query</button>
|
|
</form><p>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
if (isset($_GET['group'])) {
|
|
$group = urlencode($_GET['group']); // Encode the group name for URL
|
|
$url = "http://10.34.115.140:5000/gpo?group=$group"; // API endpoint
|
|
// Initialize cURL session
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
// Execute the request and fetch the response
|
|
$response = curl_exec($ch);
|
|
|
|
// Check for errors
|
|
if ($e = curl_error($ch)) {
|
|
die("Curl error: $e");
|
|
} else {
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
if ($httpCode != 200) {
|
|
die("Error: Received HTTP code $httpCode");
|
|
}
|
|
}
|
|
|
|
// Decode the JSON response
|
|
$data = json_decode($response, true);
|
|
|
|
// Display the data in a table
|
|
if (isset($data['error'])) {
|
|
echo "<p>Error: {$data['error']}</p>";
|
|
} else {
|
|
echo "<table><tr><th>AD Group</th><th>GPO</th><th>Local Group</th></tr>";
|
|
foreach ($data as $item) {
|
|
echo "<tr><td>{$item['ad_group']}</td><td>{$item['gpo']}</td><td>{$item['local_group']}</td></tr>";
|
|
}
|
|
echo "</table>";
|
|
}
|
|
|
|
// Close cURL session
|
|
curl_close($ch);
|
|
} else {
|
|
echo "<p>No group specified.</p>";
|
|
}
|
|
?>
|
|
|
|
</body>
|
|
</html>
|