add few tools

This commit is contained in:
2026-01-20 16:26:36 +05:30
parent f81c3e0649
commit 8ca117c04c
34 changed files with 3172 additions and 258 deletions

View File

@@ -1,36 +1,72 @@
<section class="diZContainer diZmxAuto">
<h2 class="diZBorderBottom">Domain MX Information Viewer</h2>
<p class="diZTextJustify diZmb4">The Domain MX Information Viewer is a powerful and easy-to-use tool designed to help IT professionals and website administrators retrieve detailed mail exchange (MX) records for any given domain. Simply enter a domain name, and this tool will perform a DNS lookup to fetch and display the MX records, providing insights into the domain's email routing information.</p>
<form method="post" class="diZToolsSection diZmt4 diZmb4 diZBorderRadius diZPadding5px ">
<div class="diZFlexRowCol diZJustifyCenter diZItemsCenter">
<input class="diZmr2 diZw70" placeholder="Domain Name" id="Domain" name="domain" type="text" required />
<button class="diZmr2" type="submit"><span>Check</span></button>
</div>
</form>
<?php
if (isset($_POST['domain']) && $_POST['domain']) {
function validateDomain($domain) {
return filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);
}
<?php
/**
* Domain MX Information API
* Endpoint: /dns-tools-get-mx-info
* Method: POST
* Content-Type: application/json
*/
$domain = $_POST['domain'];
if (validateDomain($domain)) {
$command = escapeshellcmd('dig ' . $domain . ' MX');
$output = shell_exec($command);
echo '<div class="diZContainer diZmxAuto diZPadding5px"><pre>' . htmlspecialchars($output, ENT_QUOTES, 'UTF-8') . '</pre></div>';
} else {
echo '<div class="diZContainer diZmxAuto diZPadding5px">Invalid domain.</div>';
}
}
?>
<div class="diZmy20">
<h3>Key Features:</h3>
<ul>
<li><strong>Accurate Domain Validation:</strong> Ensures the entered domain name is valid and properly formatted.</li>
<li><strong>Secure Processing:</strong> Utilizes command sanitization and output encoding to prevent security vulnerabilities like command injection and cross-site scripting (XSS).</li>
<li><strong>Instant Results:</strong> Quickly retrieves and displays MX records for the specified domain.</li>
<li><strong>User-Friendly Interface:</strong> Simplified input form for easy use without the need for additional styling.</li>
</ul>
<p>This tool is ideal for those seeking quick and reliable MX record information to manage and troubleshoot email delivery issues effectively.</p>
</div>
</section>
header('Content-Type: application/json; charset=utf-8');
// Allow only POST requests
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode([
'success' => false,
'message' => 'Only POST method allowed'
]);
exit;
}
// Read JSON body
$input = json_decode(file_get_contents('php://input'), true);
$domain = $input['domain'] ?? '';
// Domain validation
function validateDomain(string $domain): bool
{
return (bool) filter_var(
$domain,
FILTER_VALIDATE_DOMAIN,
FILTER_FLAG_HOSTNAME
);
}
if (!$domain || !validateDomain($domain)) {
http_response_code(400);
echo json_encode([
'success' => false,
'message' => 'Invalid domain'
]);
exit;
}
// Fetch MX records (safe, no shell_exec)
$records = dns_get_record($domain, DNS_MX);
$mxRecords = [];
if ($records !== false) {
foreach ($records as $record) {
$mxRecords[] = [
'mail_server' => $record['target'] ?? '',
'priority' => $record['pri'] ?? null
];
}
}
// Response
if (empty($mxRecords)) {
echo json_encode([
'success' => false,
'domain' => $domain,
'message' => 'No MX records found',
'records' => []
]);
exit;
}
echo json_encode([
'success' => true,
'domain' => $domain,
'records' => $mxRecords
]);