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,34 +1,85 @@
<section class="diZContainer diZmxAuto">
<h2 class="diZBorderBottom">Ultimate Domain & IP Lookup Tool</h2>
</section>
<!-- <p class="diZTextJustify">Discover detailed information about any domain and IP address with ease using Who-Is. Our tool provides instant access to essential data, including ownership, registration details, and more, all in a user-friendly interface designed for efficiency and accuracy.</p> -->
<?php
/**
* DNS A Record Lookup API
* Endpoint: /dns-tools-get-a-record
* Method: POST
* Content-Type: application/json
*/
<form method="post" class="diZToolsSection diZmt4 diZmb4 diZBorderRadius diZPadding5px">
<div class="diZFlexRowCol diZJustifyCenter diZItemsCenter">
<input class="diZmr2 diZw70" placeholder="Domain" name="domain" type="text" />
</div>
</form>
<?php
if(isset($_POST['domain']) && $_POST['domain']){
function validateDomain($domain) {
$regex = "/^(?!\-)(?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]\.)+[a-zA-Z]{2,}$/";
if (preg_match($regex, $domain)) {
return true;
} else {
return false;
}
}
// -------------------------------
// Response headers
// -------------------------------
header('Content-Type: application/json; charset=utf-8');
$domain = isset($_POST['domain']) ? $_POST['domain'] : '';
if ($domain && validateDomain($domain)) {
$command = 'dig '.$_POST['domain'].' A +short';
$escaped_command = escapeshellcmd($command);
$output = shell_exec($escaped_command);
echo '<div class="diZContainer diZmxAuto diZPadding5px"><pre class="diZTextJustify" style="width: fit-content;"> ',$output, '</pre> <br><br></div>';
} else {
echo "Invalid domain.";
// -------------------------------
// Allow only POST
// -------------------------------
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode([
'success' => false,
'message' => 'Only POST method allowed'
]);
exit;
}
// -------------------------------
// Read JSON body
// -------------------------------
$rawInput = file_get_contents('php://input');
$data = json_decode($rawInput, true);
$domain = $data['domain'] ?? '';
// -------------------------------
// Domain validation
// -------------------------------
function validateDomain(string $domain): bool
{
return (bool) preg_match(
'/^(?!-)(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$/',
$domain
);
}
if (!$domain || !validateDomain($domain)) {
http_response_code(400);
echo json_encode([
'success' => false,
'message' => 'Invalid domain'
]);
exit;
}
// -------------------------------
// DNS lookup (NO shell_exec)
// -------------------------------
$records = dns_get_record($domain, DNS_A);
$ips = [];
if ($records !== false) {
foreach ($records as $record) {
if (!empty($record['ip'])) {
$ips[] = $record['ip'];
}
}
?>
}
// -------------------------------
// Response
// -------------------------------
if (empty($ips)) {
echo json_encode([
'success' => false,
'domain' => $domain,
'message' => 'No A records found',
'ips' => []
]);
exit;
}
echo json_encode([
'success' => true,
'domain' => $domain,
'ips' => $ips
]);