mirror of https://github.com/TildeNIC/site.git
Update includes/main.php
This commit is contained in:
parent
6a6d54701f
commit
bfd408937e
|
@ -1,130 +1,131 @@
|
||||||
<?php
|
<?php
|
||||||
require_once 'initdb.php';
|
require_once 'initdb.php';
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
// Logout handling
|
// Logout handling
|
||||||
if (isset($_GET['action']) && $_GET['action'] == 'logout') {
|
if (isset($_GET['action']) && $_GET['action'] == 'logout') {
|
||||||
session_destroy();
|
session_destroy();
|
||||||
header('Location: /');
|
header('Location: /');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to get DNS server information from BIND files
|
// Function to get DNS server information from BIND files
|
||||||
function getDnsServersInfo() {
|
function getDnsServersInfo() {
|
||||||
$masterFile = '../dottilde/db.master.tilde';
|
$masterFile = '../dottilde/db.master.tilde';
|
||||||
$servers = [];
|
$servers = [];
|
||||||
$nsFilter = ['ns1', 'ns2']; // Add more nameserver identifiers as needed
|
$nsFilter = ['ns1', 'ns2','ns3']; // Add more nameserver identifiers as needed
|
||||||
|
|
||||||
// Manually assigned geographical areas for each nameserver
|
// Manually assigned geographical areas for each nameserver
|
||||||
$nsGeographicalAreas = [
|
$nsGeographicalAreas = [
|
||||||
'ns1' => 'Quebec, Canada', // Replace with actual locations
|
'ns1' => 'Quebec, Canada', // Replace with actual locations
|
||||||
'ns2' => 'Frankfurt, Germany',
|
'ns2' => 'Frankfurt, Germany',
|
||||||
// Add more as needed
|
'ns3' => 'Sydney, Australia',
|
||||||
];
|
// Add more as needed
|
||||||
|
];
|
||||||
if (file_exists($masterFile)) {
|
|
||||||
$content = file_get_contents($masterFile);
|
if (file_exists($masterFile)) {
|
||||||
// Regex to match A records (IPv4)
|
$content = file_get_contents($masterFile);
|
||||||
preg_match_all('/(\S+)\s+IN\s+A\s+(\S+)/', $content, $aMatches);
|
// Regex to match A records (IPv4)
|
||||||
// Regex to match AAAA records (IPv6)
|
preg_match_all('/(\S+)\s+IN\s+A\s+(\S+)/', $content, $aMatches);
|
||||||
preg_match_all('/(\S+)\s+IN\s+AAAA\s+(\S+)/', $content, $aaaaMatches);
|
// Regex to match AAAA records (IPv6)
|
||||||
|
preg_match_all('/(\S+)\s+IN\s+AAAA\s+(\S+)/', $content, $aaaaMatches);
|
||||||
$ipv4Records = array_combine($aMatches[1], $aMatches[2]);
|
|
||||||
$ipv6Records = array_combine($aaaaMatches[1], $aaaaMatches[2]);
|
$ipv4Records = array_combine($aMatches[1], $aMatches[2]);
|
||||||
|
$ipv6Records = array_combine($aaaaMatches[1], $aaaaMatches[2]);
|
||||||
foreach ($nsFilter as $nsName) {
|
|
||||||
$ipv4 = isset($ipv4Records[$nsName]) ? $ipv4Records[$nsName] : 'IPv4 not found';
|
foreach ($nsFilter as $nsName) {
|
||||||
$ipv6 = isset($ipv6Records[$nsName]) ? $ipv6Records[$nsName] : 'IPv6 not found';
|
$ipv4 = isset($ipv4Records[$nsName]) ? $ipv4Records[$nsName] : 'IPv4 not found';
|
||||||
$geographicalArea = isset($nsGeographicalAreas[$nsName]) ? $nsGeographicalAreas[$nsName] : 'Unknown Location';
|
$ipv6 = isset($ipv6Records[$nsName]) ? $ipv6Records[$nsName] : 'IPv6 not found';
|
||||||
|
$geographicalArea = isset($nsGeographicalAreas[$nsName]) ? $nsGeographicalAreas[$nsName] : 'Unknown Location';
|
||||||
$servers[] = [
|
|
||||||
'hostname' => $nsName,
|
$servers[] = [
|
||||||
'ipv4' => $ipv4,
|
'hostname' => $nsName,
|
||||||
'ipv6' => $ipv6,
|
'ipv4' => $ipv4,
|
||||||
'location' => $geographicalArea
|
'ipv6' => $ipv6,
|
||||||
];
|
'location' => $geographicalArea
|
||||||
}
|
];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $servers;
|
|
||||||
}
|
return $servers;
|
||||||
|
}
|
||||||
$dnsServers = getDnsServersInfo();
|
|
||||||
|
$dnsServers = getDnsServersInfo();
|
||||||
// Function to check server status
|
|
||||||
function checkServerStatus($server) {
|
// Function to check server status
|
||||||
// Ping command varies depending on the operating system
|
function checkServerStatus($server) {
|
||||||
// This is an example for a Unix-like system
|
// Ping command varies depending on the operating system
|
||||||
$output = [];
|
// This is an example for a Unix-like system
|
||||||
$status = null;
|
$output = [];
|
||||||
exec("ping -c 1 " . escapeshellarg($server), $output, $status);
|
$status = null;
|
||||||
|
exec("ping -c 1 " . escapeshellarg($server), $output, $status);
|
||||||
return $status === 0 ? "Online" : "Offline";
|
|
||||||
}
|
return $status === 0 ? "Online" : "Offline";
|
||||||
|
}
|
||||||
?>
|
|
||||||
|
?>
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
<!DOCTYPE html>
|
||||||
<head>
|
<html lang="en">
|
||||||
<meta charset="UTF-8">
|
<head>
|
||||||
<title>|--===TildeNIC ===--| Bringing .tilde to the Tildeverse!</title>
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="css/styles.css">
|
<title>|--===TildeNIC ===--| Bringing .tilde to the Tildeverse!</title>
|
||||||
</head>
|
<link rel="stylesheet" href="css/styles.css">
|
||||||
<body>
|
</head>
|
||||||
<header>
|
<body>
|
||||||
<nav>
|
<header>
|
||||||
<?php if (!isset($_SESSION['username'])): ?>
|
<nav>
|
||||||
<a href="/?page=login">Login</a> |
|
<?php if (!isset($_SESSION['username'])): ?>
|
||||||
<a href="/?page=register">Register</a>
|
<a href="/?page=login">Login</a> |
|
||||||
<?php else: ?>
|
<a href="/?page=register">Register</a>
|
||||||
<a href="/?page=main">Home</a> |
|
<?php else: ?>
|
||||||
<a href="/?page=user_domains">My Account</a> |
|
<a href="/?page=main">Home</a> |
|
||||||
<a href="/?page=domain_register">Register Domain</a> |
|
<a href="/?page=user_domains">My Account</a> |
|
||||||
<a href="/?page=main&action=logout">Logout</a><br><br>
|
<a href="/?page=domain_register">Register Domain</a> |
|
||||||
<span>Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?></span>
|
<a href="/?page=main&action=logout">Logout</a><br><br>
|
||||||
<?php endif; ?>
|
<span>Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?></span>
|
||||||
</nav>
|
<?php endif; ?>
|
||||||
</header>
|
</nav>
|
||||||
|
</header>
|
||||||
<div class="content">
|
|
||||||
<h1>Welcome to TildeNIC</h1>
|
<div class="content">
|
||||||
<div class="info-section">
|
<h1>Welcome to TildeNIC</h1>
|
||||||
<p>TildeNIC is where you can request your .tilde top level domain. To do so, you need to first change your DNS over to one of the resolvers we offer, or you can self-host one.</p>
|
<div class="info-section">
|
||||||
<ul>
|
<p>TildeNIC is where you can request your .tilde top level domain. To do so, you need to first change your DNS over to one of the resolvers we offer, or you can self-host one.</p>
|
||||||
<li><a href="https://tildegit.org/tildenic/.tilde/wiki/Setting-up-a-.tilde-DNS-server" target="_blank">Self-host information</a></li>
|
<ul>
|
||||||
</ul>
|
<li><a href="https://tildegit.org/tildenic/.tilde/wiki/Setting-up-a-.tilde-DNS-server" target="_blank">Self-host information</a></li>
|
||||||
<p><strong>NOTE!</strong> None of the servers currently listed are functional. They are old IP addresses. New servers will be online very soon!</p>
|
</ul>
|
||||||
<h3>
|
<p><strong>NOTE!</strong> None of the servers currently listed are functional. They are old IP addresses. New servers will be online very soon!</p>
|
||||||
<a href="https://opennic.org/" target="_blank">OpenNIC Information</a>
|
<h3>
|
||||||
</h3>
|
<a href="https://opennic.org/" target="_blank">OpenNIC Information</a>
|
||||||
<p>
|
</h3>
|
||||||
Domains offered by OpenNIC are also able to be resolved using our servers, Such as:
|
<p>
|
||||||
<ul>
|
Domains offered by OpenNIC are also able to be resolved using our servers, Such as:
|
||||||
<li>.geek</li>
|
<ul>
|
||||||
<li>.bbs</li>
|
<li>.geek</li>
|
||||||
<li>.gopher and more.</li>
|
<li>.bbs</li>
|
||||||
</ul>
|
<li>.gopher and more.</li>
|
||||||
Will all resolve using our dns servers. For more information about OpenNIC you can visit <a href="https://opennic.org/" target="_blank">http://opennic.org</a>
|
</ul>
|
||||||
</p>
|
Will all resolve using our dns servers. For more information about OpenNIC you can visit <a href="https://opennic.org/" target="_blank">http://opennic.org</a>
|
||||||
</div>
|
</p>
|
||||||
|
</div>
|
||||||
<div class="server-list">
|
|
||||||
<h2>TildeNIC Available DNS Servers</h2>
|
<div class="server-list">
|
||||||
<ul>
|
<h2>TildeNIC Available DNS Servers</h2>
|
||||||
<?php foreach ($dnsServers as $server): ?>
|
<ul>
|
||||||
<li>
|
<?php foreach ($dnsServers as $server): ?>
|
||||||
<?php echo htmlspecialchars($server['hostname']); ?> -
|
<li>
|
||||||
IPv4: <?php echo htmlspecialchars($server['ipv4']); ?>,
|
<?php echo htmlspecialchars($server['hostname']); ?> -
|
||||||
IPv6: <?php echo htmlspecialchars($server['ipv6']); ?>,
|
IPv4: <?php echo htmlspecialchars($server['ipv4']); ?>,
|
||||||
Location: <?php echo htmlspecialchars($server['location']); ?> -
|
IPv6: <?php echo htmlspecialchars($server['ipv6']); ?>,
|
||||||
<span class="status <?php echo checkServerStatus($server['hostname']) === 'Online' ? 'online' : 'offline'; ?>">
|
Location: <?php echo htmlspecialchars($server['location']); ?> -
|
||||||
<?php echo checkServerStatus($server['hostname']); ?>
|
<span class="status <?php echo checkServerStatus($server['hostname']) === 'Online' ? 'online' : 'offline'; ?>">
|
||||||
</span>
|
<?php echo checkServerStatus($server['hostname']); ?>
|
||||||
</li>
|
</span>
|
||||||
<?php endforeach; ?>
|
</li>
|
||||||
</ul>
|
<?php endforeach; ?>
|
||||||
</div>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</div>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue