add few tools
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require_once('../.hta_config/conf.php');
|
||||
require_once('../.hta_slug/_header.php');
|
||||
require_once('../.hta_slug/_nav.php');
|
||||
require_once(__DIR__.'/../.hta_config/conf.php');
|
||||
require_once(__DIR__.'/../.hta_slug/_header.php');
|
||||
require_once(__DIR__.'/../.hta_slug/_nav.php');
|
||||
?>
|
||||
|
||||
<section class="diZContainer diZmxAuto diZmb20">
|
||||
|
||||
0
.hta_slug/_footer.php
Normal file
0
.hta_slug/_footer.php
Normal file
0
.hta_slug/_header.php
Normal file
0
.hta_slug/_header.php
Normal file
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
require_once('../.hta_config/conf.php');
|
||||
require_once('../.hta_slug/_header.php');
|
||||
require_once('../.hta_slug/_nav.php');
|
||||
require_once(__DIR__.'/../.hta_config/conf.php');
|
||||
require_once(__DIR__.'/../.hta_slug/_header.php');
|
||||
require_once(__DIR__.'/../.hta_slug/_nav.php');
|
||||
?>
|
||||
|
||||
<section class="diZContainer diZmxAuto diZmb20">
|
||||
|
||||
0
.hta_slug/_nav.php
Normal file
0
.hta_slug/_nav.php
Normal 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
|
||||
]);
|
||||
|
||||
@@ -1,34 +1,71 @@
|
||||
<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 MX Record Lookup API
|
||||
* Endpoint: /dns-tools-get-mx-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;
|
||||
}
|
||||
}
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$domain = isset($_POST['domain']) ? $_POST['domain'] : '';
|
||||
if ($domain && validateDomain($domain)) {
|
||||
$command = 'dig '.$_POST['domain'].' MX +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 input
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$domain = $input['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;
|
||||
}
|
||||
|
||||
// Fetch MX records
|
||||
$records = dns_get_record($domain, DNS_MX);
|
||||
$mxRecords = [];
|
||||
|
||||
if ($records !== false) {
|
||||
foreach ($records as $record) {
|
||||
$mxRecords[] = [
|
||||
'host' => $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
|
||||
]);
|
||||
|
||||
@@ -1,34 +1,70 @@
|
||||
<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 NS Record Lookup API
|
||||
* Endpoint: /dns-tools-get-ns-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;
|
||||
}
|
||||
}
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$domain = isset($_POST['domain']) ? $_POST['domain'] : '';
|
||||
if ($domain && validateDomain($domain)) {
|
||||
$command = 'dig '.$_POST['domain'].' NS +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 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) 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;
|
||||
}
|
||||
|
||||
// Fetch NS records
|
||||
$records = dns_get_record($domain, DNS_NS);
|
||||
$nsRecords = [];
|
||||
|
||||
if ($records !== false) {
|
||||
foreach ($records as $record) {
|
||||
if (!empty($record['target'])) {
|
||||
$nsRecords[] = $record['target'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
|
||||
// Response
|
||||
if (empty($nsRecords)) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'domain' => $domain,
|
||||
'message' => 'No NS records found',
|
||||
'records' => []
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'domain' => $domain,
|
||||
'records' => $nsRecords
|
||||
]);
|
||||
|
||||
@@ -1,118 +1,83 @@
|
||||
<?php
|
||||
require '.hta_lib/vendors/maxmind-db-reader/vendor/autoload.php';
|
||||
?>
|
||||
<section class="diZContainer diZmxAuto diZmy8">
|
||||
<h1 class="diZBorderBottom">IP Information</h1>
|
||||
<p>This tool provides detailed geographical and ISP information for a given IP address using the GeoIP2.</p>
|
||||
<?php
|
||||
use GeoIp2\Database\Reader;
|
||||
if (isset($_GET['ip'])) {
|
||||
try {
|
||||
$reader = new Reader('.hta_lib/data/GeoLite2-City.mmdb');
|
||||
$reader2 = new Reader('.hta_lib/data/GeoLite2-ASN.mmdb');
|
||||
// ❌ No header() here
|
||||
|
||||
$records = $reader->city($_GET['ip']);
|
||||
$records2 = $reader2->asn($_GET['ip']);
|
||||
// var_dump($records2);
|
||||
$country = $records->country->name ?? null;
|
||||
$state = $records->mostSpecificSubdivision->name ?? null;
|
||||
$city = $records->city->name ?? null;
|
||||
$region = $records->subdivisions[0]->name ?? null;
|
||||
$timezone = $records->location->timeZone ?? null;
|
||||
require_once __DIR__ . '/../.hta_lib/maxmind-db-reader/autoload.php';
|
||||
|
||||
$data = [
|
||||
'ip' => $_GET['ip'],
|
||||
'country' => $records->country->name ?? null,
|
||||
'country_iso_code' => $records->country->iso_code ?? null,
|
||||
'state' => $records->mostSpecificSubdivision->name ?? null,
|
||||
'state_iso_code' => $records->mostSpecificSubdivision->iso_code ?? null,
|
||||
'city' => $records->city->name ?? null,
|
||||
'region' => $records->subdivisions[0]->name ?? null,
|
||||
'timezone' => $records->location->timeZone ?? null,
|
||||
'latitude' => $records->location->latitude ?? null,
|
||||
'longitude' => $records->location->longitude ?? null,
|
||||
'postal_code' => $records->postal->code ?? null,
|
||||
'continent' => $records->continent->name ?? null,
|
||||
'asn' => $records2->autonomousSystemNumber ?? null,
|
||||
'isp' => $records2->autonomousSystemOrganization ?? null,
|
||||
];
|
||||
$dataArray = [$data]; // Wrap in an array if it's a single record.
|
||||
?>
|
||||
<div class="diZGridCols1-3">
|
||||
<?php
|
||||
foreach ($dataArray as $record) { // Ensure you loop through an array
|
||||
if (is_array($record)) { // Check if record is an array
|
||||
?>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>IP:</strong> <?php echo $record['ip']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>Continent:</strong> <?php echo $record['continent']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>Country:</strong> <?php echo $record['country']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>State:</strong> <?php echo $record['state']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>City:</strong> <?php echo $record['city']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>Region:</strong> <?php echo $record['region']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>Timezone:</strong> <?php echo $record['timezone']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>Latitude:</strong> <?php echo $record['latitude']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>Longitude:</strong> <?php echo $record['longitude']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>Postal Code:</strong> <?php echo $record['postal_code']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>ASN:</strong> <?php echo $record['asn']; ?></h3>
|
||||
<h3 style="border-bottom: 1px solid #808080;"><strong>ISP:</strong> <?php echo $record['isp']; ?></h3>
|
||||
<?php
|
||||
} else {
|
||||
echo '<p>Invalid data format</p><br>';
|
||||
echo '<div class="diZFlexColumn diZmxAuto diZJustifyCenter diZItemsCenter">
|
||||
<a class="diZButtonDenger " href="/tools/location-ip-to-location">Back</a>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="diZFlexColumn diZmxAuto diZJustifyCenter diZItemsCenter">
|
||||
<a class="diZButtonDenger " href="/tools/location-ip-to-location">Back</a>
|
||||
</div>
|
||||
<?php
|
||||
// Echoing the data as JSON
|
||||
// echo json_encode($data);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
echo '<div class="diZFlexColumn diZmxAuto diZJustifyCenter diZItemsCenter">
|
||||
<a class="diZButtonDenger " href="/tools/location-ip-to-location">Back</a>
|
||||
</div>';
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
<div class="diZMaxW600 diZw100 diZmxAuto toolsSection diZFlexColumn diZmy20"><br>
|
||||
<form method="get" class="diZFlexColumn">
|
||||
<label for="ip">IP Address:</label>
|
||||
<div class="diZFlexColumn">
|
||||
<input class="diZPadding5px" type="text" name="ip" id="ip" placeholder="Enter IP Address" />
|
||||
<button class="diZmxAuto diZmt4" type="submit"><span>Check IP Details</span></button>
|
||||
</div>
|
||||
</form><br>
|
||||
</div>
|
||||
<!-- echo json_encode(['error' => 'Invalid parameters']); diZw100 -->
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<div>
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<li><strong>Enter IP Address:</strong> Input the IP address you wish to check in the provided query parameter.</li>
|
||||
<li><strong>Check Location:</strong> Send a request with the IP address to retrieve and display the geographical and ISP information.</li>
|
||||
<li><strong>View Results:</strong> The location and ISP details will be displayed in a structured format, showing country, city, region, ASN, ISP, and other relevant information.</li>
|
||||
</ul>
|
||||
|
||||
<h3>Features:</h3>
|
||||
<ul>
|
||||
<li>Uses MaxMind GeoLite2 databases for accurate geo-location and ISP information.</li>
|
||||
<li>Displays detailed geographical information including continent, country, state, city, and region.</li>
|
||||
<li>Provides additional information such as timezone, latitude, longitude, and postal code.</li>
|
||||
<li>Displays Autonomous System Number (ASN) and Internet Service Provider (ISP) details.</li>
|
||||
</ul>
|
||||
<h3>Example Use Cases:</h3>
|
||||
<ul>
|
||||
<li>Network administrators tracking the location of IP addresses accessing their networks.</li>
|
||||
<li>Security professionals analyzing IP addresses for potential threats.</li>
|
||||
<li>Developers building applications that require IP-based location services.</li>
|
||||
<li>Marketers tailoring content based on the geographic location of their audience.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
use MaxMind\Db\Reader;
|
||||
|
||||
function respond($status, $data = null, $error = null)
|
||||
{
|
||||
echo json_encode([
|
||||
'success' => $status,
|
||||
'data' => $data,
|
||||
'error' => $error
|
||||
], JSON_PRETTY_PRINT);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($_GET['ip']) || trim($_GET['ip']) === '') {
|
||||
respond(false, null, 'IP parameter is required');
|
||||
}
|
||||
|
||||
$ip = trim($_GET['ip']);
|
||||
|
||||
if (!filter_var($ip, FILTER_VALIDATE_IP)) {
|
||||
respond(false, null, 'Invalid IP address');
|
||||
}
|
||||
|
||||
try {
|
||||
$cityReader = new Reader(__DIR__ . '/../.hta_lib/data/GeoLite2-City.mmdb');
|
||||
$asnReader = new Reader(__DIR__ . '/../.hta_lib/data/GeoLite2-ASN.mmdb');
|
||||
|
||||
$cityData = $cityReader->get($ip);
|
||||
$asnData = $asnReader->get($ip);
|
||||
|
||||
$cityReader->close();
|
||||
$asnReader->close();
|
||||
|
||||
$response = [
|
||||
'ip' => $ip,
|
||||
|
||||
'continent' => [
|
||||
'name' => $cityData['continent']['names']['en'] ?? null,
|
||||
'code' => $cityData['continent']['code'] ?? null
|
||||
],
|
||||
|
||||
'country' => [
|
||||
'name' => $cityData['country']['names']['en'] ?? null,
|
||||
'code' => $cityData['country']['iso_code'] ?? null
|
||||
],
|
||||
|
||||
'state' => [
|
||||
'name' => $cityData['subdivisions'][0]['names']['en'] ?? null,
|
||||
'code' => $cityData['subdivisions'][0]['iso_code'] ?? null
|
||||
],
|
||||
|
||||
'city' => $cityData['city']['names']['en'] ?? null,
|
||||
|
||||
'timezone' => $cityData['location']['time_zone'] ?? null,
|
||||
|
||||
'location' => [
|
||||
'latitude' => $cityData['location']['latitude'] ?? null,
|
||||
'longitude' => $cityData['location']['longitude'] ?? null
|
||||
],
|
||||
|
||||
'postal_code' => $cityData['postal']['code'] ?? null,
|
||||
|
||||
'asn' => [
|
||||
'number' => $asnData['autonomous_system_number'] ?? null,
|
||||
'org' => $asnData['autonomous_system_organization'] ?? null
|
||||
],
|
||||
];
|
||||
|
||||
$anycastASN = [15169, 13335, 36692];
|
||||
$response['is_anycast'] = in_array($response['asn']['number'], $anycastASN);
|
||||
$response['note'] = $response['is_anycast']
|
||||
? 'Anycast IP detected. Location may vary.'
|
||||
: 'IP-based location is approximate.';
|
||||
|
||||
respond(true, $response);
|
||||
|
||||
} catch (Exception $e) {
|
||||
respond(false, null, $e->getMessage());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user