updates
This commit is contained in:
parent
a0d32ba8fe
commit
61421c7294
|
@ -42,12 +42,12 @@ function generateDnsFileContent($domain, $ipAddress) {
|
|||
chdir('../dottilde');
|
||||
|
||||
// Perform a git pull to ensure the repository is up to date
|
||||
exec('git pull');
|
||||
exec('git pull 2>&1', $gitOutput, $gitStatus);
|
||||
writeToLog("Git Pull: " . implode("\n", $gitOutput), $logFile);
|
||||
|
||||
// Fetch domains and generate DNS files
|
||||
$domains = getAllDomains($pdo);
|
||||
$changes = false;
|
||||
$currentFiles = glob('db.*'); // Get all current db files
|
||||
$currentFiles = glob('db.*');
|
||||
|
||||
writeToLog("Current files before processing: " . implode(', ', $currentFiles), $logFile);
|
||||
|
||||
|
@ -76,12 +76,16 @@ foreach ($currentFiles as $file) {
|
|||
$changes = true;
|
||||
}
|
||||
|
||||
// Close the log file
|
||||
fclose($logFile);
|
||||
|
||||
// Git commit and push if there are changes
|
||||
if ($changes) {
|
||||
exec('git add .');
|
||||
exec('git commit -m "Updated DNS files"');
|
||||
exec('git push origin master');
|
||||
}
|
||||
exec('git add . 2>&1', $gitAddOutput, $gitAddStatus);
|
||||
writeToLog("Git Add: " . implode("\n", $gitAddOutput), $logFile);
|
||||
|
||||
exec('git commit -m "Updated DNS files" 2>&1', $gitCommitOutput, $gitCommitStatus);
|
||||
writeToLog("Git Commit: " . implode("\n", $gitCommitOutput), $logFile);
|
||||
|
||||
exec('git push origin master 2>&1', $gitPushOutput, $gitPushStatus);
|
||||
writeToLog("Git Push: " . implode("\n", $gitPushOutput), $logFile);
|
||||
}
|
||||
|
||||
fclose($logFile);
|
||||
?>
|
|
@ -113,11 +113,13 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['registerdomain'])) {
|
|||
<nav>
|
||||
<?php if (!isset($_SESSION['username'])): ?>
|
||||
<a href="https://tildenic.org/?page=login">Login</a> |
|
||||
<a href="https://tildenic.org/?page=register">Register</a>
|
||||
<a href="https://tildenic.org/?page=register">Register</a> |
|
||||
<a href="/?page=whois">WHOIS</a>
|
||||
<?php else: ?>
|
||||
<a href="https://tildenic.org/?page=main">Home</a> |
|
||||
<a href="https://tildenic.org/?page=user_domains">My Account</a> |
|
||||
<a href="https://tildenic.org/?page=domain_register">Register Domain</a> |
|
||||
<a href="/?page=whois">WHOIS</a> |
|
||||
<a href="https://tildenic.org/?page=main&action=logout">Logout</a><br><br>
|
||||
<span>Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?></span>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -52,17 +52,22 @@ function getDnsServersInfo() {
|
|||
|
||||
$dnsServers = getDnsServersInfo();
|
||||
|
||||
// Function to check server status
|
||||
// Modified checkServerStatus function
|
||||
function checkServerStatus($server) {
|
||||
$port = 53; // DNS port, change if necessary
|
||||
$timeout = 10; // Timeout in seconds
|
||||
$timeout = 30; // Timeout in seconds
|
||||
|
||||
// Debug: Output the server being checked
|
||||
# echo "Checking status of server: $server<br>";
|
||||
|
||||
$fp = @fsockopen($server, $port, $errno, $errstr, $timeout);
|
||||
|
||||
if ($fp) {
|
||||
fclose($fp);
|
||||
# echo "Server $server is Online<br>"; // Debug: Server is online
|
||||
return "Online";
|
||||
} else {
|
||||
# echo "Server $server is Offline - Error: $errstr ($errno)<br>"; // Debug: Server is offline
|
||||
return "Offline";
|
||||
}
|
||||
}
|
||||
|
@ -79,12 +84,15 @@ function checkServerStatus($server) {
|
|||
<header>
|
||||
<nav>
|
||||
<?php if (!isset($_SESSION['username'])): ?>
|
||||
<a href="/?page=main">Home</a> |
|
||||
<a href="/?page=login">Login</a> |
|
||||
<a href="/?page=register">Register</a>
|
||||
<a href="/?page=register">Register</a> |
|
||||
<a href="/?page=whois">WHOIS</a>
|
||||
<?php else: ?>
|
||||
<a href="/?page=main">Home</a> |
|
||||
<a href="/?page=user_domains">My Account</a> |
|
||||
<a href="/?page=domain_register">Register Domain</a> |
|
||||
<a href="/?page=whois">WHOIS</a> |
|
||||
<a href="/?page=main&action=logout">Logout</a><br><br>
|
||||
<span>Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?></span>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
require_once 'initdb.php';
|
||||
session_start();
|
||||
|
||||
// Logout handling
|
||||
if (isset($_GET['action']) && $_GET['action'] == 'logout') {
|
||||
session_destroy();
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
|
||||
// Function to get DNS server information from BIND files
|
||||
function getDnsServersInfo() {
|
||||
$masterFile = '../dottilde/db.master.tilde';
|
||||
$servers = [];
|
||||
$nsFilter = ['ns1', 'ns2', 'ns3']; // Add more nameserver identifiers as needed
|
||||
|
||||
// Manually assigned geographical areas for each nameserver
|
||||
$nsGeographicalAreas = [
|
||||
'ns1' => 'Quebec, Canada', // Replace with actual locations
|
||||
'ns2' => 'Frankfurt, Germany',
|
||||
'ns3' => 'Sydney, Australia',
|
||||
// Add more as needed
|
||||
];
|
||||
|
||||
if (file_exists($masterFile)) {
|
||||
$content = file_get_contents($masterFile);
|
||||
// Regex to match A records (IPv4)
|
||||
preg_match_all('/(\S+)\s+IN\s+A\s+(\S+)/', $content, $aMatches);
|
||||
// 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]);
|
||||
|
||||
foreach ($nsFilter as $nsName) {
|
||||
$ipv4 = isset($ipv4Records[$nsName]) ? $ipv4Records[$nsName] : 'IPv4 not found';
|
||||
$ipv6 = isset($ipv6Records[$nsName]) ? $ipv6Records[$nsName] : 'IPv6 not found';
|
||||
$geographicalArea = isset($nsGeographicalAreas[$nsName]) ? $nsGeographicalAreas[$nsName] : 'Unknown Location';
|
||||
|
||||
$servers[] = [
|
||||
'hostname' => $nsName,
|
||||
'ipv4' => $ipv4,
|
||||
'ipv6' => $ipv6,
|
||||
'location' => $geographicalArea
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $servers;
|
||||
}
|
||||
|
||||
$dnsServers = getDnsServersInfo();
|
||||
|
||||
// Function to check server status
|
||||
function checkServerStatus($server) {
|
||||
$port = 53; // DNS port, change if necessary
|
||||
$timeout = 10; // Timeout in seconds
|
||||
|
||||
$fp = @fsockopen($server, $port, $errno, $errstr, $timeout);
|
||||
|
||||
if ($fp) {
|
||||
fclose($fp);
|
||||
return "Online";
|
||||
} else {
|
||||
return "Offline";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>|--===TildeNIC ===--| Bringing .tilde to the Tildeverse!</title>
|
||||
<link rel="stylesheet" href="css/styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav>
|
||||
<?php if (!isset($_SESSION['username'])): ?>
|
||||
<a href="/?page=login">Login</a> |
|
||||
<a href="/?page=register">Register</a>
|
||||
<?php else: ?>
|
||||
<a href="/?page=main">Home</a> |
|
||||
<a href="/?page=user_domains">My Account</a> |
|
||||
<a href="/?page=domain_register">Register Domain</a> |
|
||||
<a href="/?page=main&action=logout">Logout</a><br><br>
|
||||
<span>Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?></span>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div class="content">
|
||||
<h1>Welcome to TildeNIC</h1>
|
||||
<div class="info-section">
|
||||
<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>
|
||||
<ul>
|
||||
<li><a href="https://tildegit.org/tildenic/.tilde/wiki/Setting-up-a-.tilde-DNS-server" target="_blank">Self-host information</a></li>
|
||||
</ul>
|
||||
<h3>
|
||||
<a href="https://opennic.org/" target="_blank">OpenNIC Information</a>
|
||||
</h3>
|
||||
<p>
|
||||
Domains offered by OpenNIC are also able to be resolved using our servers, Such as:
|
||||
<ul>
|
||||
<li>.geek</li>
|
||||
<li>.bbs</li>
|
||||
<li>.gopher and more.</li>
|
||||
</ul>
|
||||
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>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="server-list">
|
||||
<h2>TildeNIC Available DNS Servers</h2>
|
||||
<ul>
|
||||
<?php foreach ($dnsServers as $server): ?>
|
||||
<li>
|
||||
<?php echo htmlspecialchars($server['hostname']); ?> -
|
||||
IPv4: <?php echo htmlspecialchars($server['ipv4']); ?>,
|
||||
IPv6: <?php echo htmlspecialchars($server['ipv6']); ?>,
|
||||
Location: <?php echo htmlspecialchars($server['location']); ?> -
|
||||
<span class="status <?php echo checkServerStatus($server['hostname']) === 'Online' ? 'online' : 'offline'; ?>">
|
||||
<?php echo checkServerStatus($server['hostname']); ?>
|
||||
</span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -199,11 +199,13 @@ $domains = getUserDomains($userId, $pdo);
|
|||
<nav>
|
||||
<?php if (!isset($_SESSION['username'])): ?>
|
||||
<a href="https://tildenic.org/?page=login">Login</a> |
|
||||
<a href="https://tildenic.org/?page=register">Register</a>
|
||||
<a href="https://tildenic.org/?page=register">Register</a> |
|
||||
<a href="/?page=whois">WHOIS</a>
|
||||
<?php else: ?>
|
||||
<a href="https://tildenic.org/?page=main">Home</a> |
|
||||
<a href="https://tildenic.org/?page=user_domains" active>My Account</a> |
|
||||
<a href="https://tildenic.org/?page=domain_register">Register Domain</a> |
|
||||
<a href="/?page=whois">WHOIS</a> |
|
||||
<a href="https://tildenic.org/?page=main&action=logout">Logout</a><br><br>
|
||||
<span>Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?></span>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
require_once 'initdb.php';
|
||||
session_start();
|
||||
|
||||
// Function to get domain information
|
||||
function getDomainInfo($domain, $pdo) {
|
||||
$stmt = $pdo->prepare("SELECT domains.domain_name, users.username, domains.ip_address, domains.created_at FROM domains JOIN users ON domains.user_id = users.id WHERE domains.domain_name = ?");
|
||||
$stmt->execute([$domain]);
|
||||
return $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
// Handle form submission
|
||||
$searchError = '';
|
||||
$domainInfo = null;
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['search'])) {
|
||||
$domain = $_POST['domain'];
|
||||
|
||||
// Adjusted regex to allow for '.tilde' extension
|
||||
if (!preg_match('/^[a-zA-Z0-9-]+\.tilde$/', $domain)) {
|
||||
$searchError = "Invalid domain format. Only letters, numbers, and hyphens followed by '.tilde' are allowed.";
|
||||
} else {
|
||||
$domainInfo = getDomainInfo($domain, $pdo);
|
||||
if (!$domainInfo) {
|
||||
$searchError = "Domain not found.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>.tilde Whois Lookup</title>
|
||||
<link rel="stylesheet" href="css/styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav>
|
||||
<?php if (!isset($_SESSION['username'])): ?>
|
||||
<a href="/?page=main">Home</a> |
|
||||
<a href="/?page=login">Login</a> |
|
||||
<a href="/?page=register">Register</a> |
|
||||
<a href="/?page=whois">WHOIS</a>
|
||||
<?php else: ?>
|
||||
<a href="/?page=main">Home</a> |
|
||||
<a href="/?page=user_domains">My Account</a> |
|
||||
<a href="/?page=domain_register">Register Domain</a> |
|
||||
<a href="/?page=whois">WHOIS</a> |
|
||||
<a href="/?page=main&action=logout">Logout</a><br><br>
|
||||
<span>Welcome, <?php echo htmlspecialchars($_SESSION['username']); ?></span>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
</header>
|
||||
<h1>.tilde Whois Lookup</h1>
|
||||
<form method="post">
|
||||
<label for="domain">Domain Name:</label>
|
||||
<input type="text" id="domain" name="domain" required>
|
||||
<input type="submit" name="search" value="Search">
|
||||
</form>
|
||||
|
||||
<?php if ($searchError): ?>
|
||||
<p><?php echo $searchError; ?></p>
|
||||
<?php elseif ($domainInfo): ?>
|
||||
<h2>Domain Information</h2>
|
||||
<p>Domain: <?php echo htmlspecialchars($domainInfo['domain_name']); ?></p>
|
||||
<p>Owner: <?php echo htmlspecialchars($domainInfo['username']); ?></p>
|
||||
<p>IP Address: <?php echo htmlspecialchars($domainInfo['ip_address']); ?></p>
|
||||
<p>Registered On: <?php echo htmlspecialchars($domainInfo['created_at']); ?></p>
|
||||
<?php endif; ?>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue