Compare commits
6 Commits
397522edcb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f3bc9a27ae | |||
| 8d4cdcf601 | |||
| 0e265ed859 | |||
| 30503e398d | |||
| 70e1f85971 | |||
| deeecc6f9c |
@@ -6,7 +6,7 @@
|
||||
$API_HEADERS = [
|
||||
'Content-Type: application/json; charset=utf-8',
|
||||
'Access-Control-Allow-Origin: *',
|
||||
'Access-Control-Allow-Methods: GET, POST, OPTIONS',
|
||||
'Access-Control-Allow-Methods: POST, OPTIONS',
|
||||
'Access-Control-Allow-Headers: Content-Type, Authorization',
|
||||
'X-Powered-By: SiliconPin Tools'
|
||||
];
|
||||
@@ -14,9 +14,20 @@ $API_HEADERS = [
|
||||
/**
|
||||
* Apply headers helper
|
||||
*/
|
||||
function applyApiHeaders(array $headers)
|
||||
function applyApiHeaders(array $headers): void
|
||||
{
|
||||
foreach ($headers as $header) {
|
||||
header($header);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle CORS preflight globally
|
||||
*/
|
||||
function handleCorsPreflight(): void
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
<?php
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type, Authorization');
|
||||
header('X-Powered-By: SiliconPin Tools');
|
||||
/**
|
||||
* DNS A Record Lookup API
|
||||
* Endpoint: /dns-tools-get-a-record
|
||||
* Method: POST
|
||||
* Content-Type: application/json
|
||||
*/
|
||||
require_once __DIR__ . '/../.hta_config/conf.php';
|
||||
|
||||
// -------------------------------
|
||||
// Response headers
|
||||
// -------------------------------
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
applyApiHeaders($API_HEADERS);
|
||||
handleCorsPreflight();
|
||||
|
||||
// -------------------------------
|
||||
// Allow only POST
|
||||
@@ -34,7 +22,21 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
$rawInput = file_get_contents('php://input');
|
||||
$data = json_decode($rawInput, true);
|
||||
|
||||
$domain = $data['domain'] ?? '';
|
||||
if (!is_array($data)) {
|
||||
http_response_code(400);
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => 'Invalid JSON payload'
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Normalize domain
|
||||
// -------------------------------
|
||||
$domain = trim($data['domain'] ?? '');
|
||||
$domain = preg_replace('#^https?://#', '', $domain);
|
||||
$domain = preg_replace('#/.*$#', '', $domain);
|
||||
|
||||
// -------------------------------
|
||||
// Domain validation
|
||||
@@ -57,15 +59,47 @@ if (!$domain || !validateDomain($domain)) {
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// DNS lookup (NO shell_exec)
|
||||
// DNS lookup with timing
|
||||
// -------------------------------
|
||||
$startTime = microtime(true);
|
||||
$records = dns_get_record($domain, DNS_A);
|
||||
$ips = [];
|
||||
$lookupTimeMs = round((microtime(true) - $startTime) * 1000, 2);
|
||||
|
||||
// -------------------------------
|
||||
// Resolver info
|
||||
// -------------------------------
|
||||
$resolver = 'hosting-default';
|
||||
|
||||
// -------------------------------
|
||||
// Provider detection (heuristic)
|
||||
// -------------------------------
|
||||
function detectProvider(string $ip): string
|
||||
{
|
||||
if (preg_match('/^(104\.|172\.6[4-7]\.)/', $ip)) {
|
||||
return 'Cloudflare';
|
||||
}
|
||||
if (preg_match('/^(13\.|15\.|52\.|54\.)/', $ip)) {
|
||||
return 'AWS';
|
||||
}
|
||||
if (preg_match('/^(34\.|35\.)/', $ip)) {
|
||||
return 'Google Cloud';
|
||||
}
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Build records
|
||||
// -------------------------------
|
||||
$result = [];
|
||||
|
||||
if ($records !== false) {
|
||||
foreach ($records as $record) {
|
||||
if (!empty($record['ip'])) {
|
||||
$ips[] = $record['ip'];
|
||||
$result[] = [
|
||||
'ip' => $record['ip'],
|
||||
'ttl' => $record['ttl'] ?? null,
|
||||
'provider' => detectProvider($record['ip'])
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,12 +107,12 @@ if ($records !== false) {
|
||||
// -------------------------------
|
||||
// Response
|
||||
// -------------------------------
|
||||
if (empty($ips)) {
|
||||
if (empty($result)) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'domain' => $domain,
|
||||
'message' => 'No A records found',
|
||||
'ips' => []
|
||||
'records' => []
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
@@ -86,5 +120,8 @@ if (empty($ips)) {
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'domain' => $domain,
|
||||
'ips' => $ips
|
||||
'record_count' => count($result),
|
||||
'lookup_time_ms' => $lookupTimeMs,
|
||||
'resolver' => $resolver,
|
||||
'records' => $result
|
||||
]);
|
||||
|
||||
26
.hta_slug/sitemap-generate.php
Normal file
26
.hta_slug/sitemap-generate.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
// stream.php
|
||||
|
||||
header("Content-Type: text/event-stream");
|
||||
header("Cache-Control: no-cache");
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
|
||||
$siteId = file_get_contents("current_site.txt");
|
||||
|
||||
for ($i = 1; $i <= 5; $i++) {
|
||||
echo "data: " . json_encode([
|
||||
"type" => "update",
|
||||
"message" => "Crawling page $i..."
|
||||
]) . "\n\n";
|
||||
ob_flush();
|
||||
flush();
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
echo "data: " . json_encode([
|
||||
"type" => "complete",
|
||||
"site_id" => trim($siteId)
|
||||
]) . "\n\n";
|
||||
|
||||
ob_flush();
|
||||
flush();
|
||||
Reference in New Issue
Block a user