First commit

This commit is contained in:
2024-06-13 09:45:05 +02:00
commit 8073f47c48
11 changed files with 2082 additions and 0 deletions

14
.eslintrc Normal file
View File

@@ -0,0 +1,14 @@
{
"extends": "eslint:recommended",
"env": {
"browser": true,
"es6" : true,
},
"rules": {
// Override our default settings just for this directory
"indent": ["error", 2],
"eqeqeq": "warn",
"strict": "off",
"arrow-body-style": ["error", "always"]
},
}

1
.php_cs Normal file
View File

@@ -0,0 +1 @@
strings_containing_single_quote_chars true

11
.prettierrc Normal file
View File

@@ -0,0 +1,11 @@
{
"singleQuote": false,
"overrides": [
{
"files": ["**/*.js"],
"options": {
"singleQuote": true
}
}
]
}

33
api/addrecord.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
// header("Content-Type: content/json");
header("Content-Type: text/plain");
function stop($error)
{
http_response_code(513);
$RESPONSE = new stdClass();
$RESPONSE->status = "error";
$RESPONSE->response = $error;
printf(json_encode($RESPONSE));
die;
}
$_SERVER['REQUEST_METHOD'] !== "POST" && stop("Method " . $_SERVER['REQUEST_METHOD'] . " not allowed");
$POST = json_decode(file_get_contents('php://input'));
$DATA = "<< EOF
server 127.0.0.1
update add $POST->name $POST->ttl $POST->class $POST->type $POST->rr
send
EOF";
passthru("/usr/bin/nsupdate $DATA", $result_code);
$result_code === 0 || stop("Unable to update zone");
$RESPONSE = new stdClass();
$RESPONSE->status = "success";
$RESPONSE->response = "zone added successfully";
printf(json_encode($RESPONSE));

47
api/getzones.php Normal file
View File

@@ -0,0 +1,47 @@
<?php
header("Content-Type: content/json");
function stop($error)
{
http_response_code(513);
printf(json_encode($error));
die;
}
$_SERVER['REQUEST_METHOD'] !== "GET" && stop("Method " . $_SERVER['REQUEST_METHOD'] . " not allowed");
$result_code = 0;
passthru("/usr/bin/rndc dumpdb -zones", $result_code);
$result_code === 0 || stop("Unable to get zone");
sleep(2);
$HANDLE = fopen("/var/named/named_dump.db", "r");
$HANDLE || stop("Unable to read zone db");
$ZONE = new stdClass();
$CURRENTZONE = "";
while (($LINE = fgets($HANDLE)) !== false) {
if (str_starts_with($LINE, ";")) continue;
$LINE = preg_split("/\s+/", $LINE);
if ($LINE[3] === "SOA") {
$CURRENTZONE = $LINE[0];
$ZONE->$CURRENTZONE = [];
}
$RECORD = new stdClass();
$RECORD->name = $LINE[0];
array_shift($LINE);
$RECORD->ttl = $LINE[0];
array_shift($LINE);
$RECORD->class = $LINE[0];
array_shift($LINE);
$RECORD->type = $LINE[0];
array_shift($LINE);
$RECORD->rr = implode(" ", $LINE);
array_push($ZONE->$CURRENTZONE, $RECORD);
unset($RECORD);
}
printf(json_encode($ZONE));

0
composer.json Normal file
View File

64
css/style.css Normal file
View File

@@ -0,0 +1,64 @@
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,400;1,700&display=swap');
:root {
--background-dark: #21252b;
--background: #282c34;
--background-light: #323842;
--foreground: #abb2bf;
--foreground-light: #d4d8df;
--foreground-lighter: #f6f7f9;
--red: #e06c75;
--green: #98c379;
--yellow: #e5c07b;
--blue: #61afef;
--purple: #c678dd;
--cyan: #56b6c2;
}
h1,
body,
html {
margin: 0;
padding: 0;
}
html,
body {
background-color: var(--background);
color: var(--foreground);
height: 100%;
font-family: Roboto;
}
body {
display: flex;
flex-direction: column;
}
header {
background-color: var(--blue);
color: var(--background);
height: 50px;
display: flex;
align-items: center;
flex-shrink: 0;
}
main {
display: flex;
height: 100%;
}
aside {
height: calc(100% - 20px);
width: 20%;
border-right: 1px solid;
margin: 10px;
}
section {
height: calc(100% - 20px);
width: 80%;
margin: 10px;
}

31
index.html Normal file
View File

@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<title>S-DNSPUBADM-P1</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet">
<script src="js/main.js"></script>
</head>
<body>
<header>
<h1>S-DNSPUBADM-P1</h1>
</header>
<main>
<aside>
<div>
asd
</div>
<div>
asd
</div>
</aside>
<section>
zone view
</section>
</main>
</body>
</html>

20
js/main.js Normal file
View File

@@ -0,0 +1,20 @@
console.log('main.js loaded');
async function update() {
const response = await fetch('http://127.0.0.1/api/getzones.php', {
method: 'GET',
});
console.log(response);
const content = await response.json();
// loop le result
// update menu with key
// loop value
// update table with value
}
window.onload = () => {
update();
};

1861
named_dump.db Normal file

File diff suppressed because it is too large Load Diff

0
tsconfig.json Normal file
View File