File: /home/internet/.trash/upload.php
<?php
ignore_user_abort(true); // Continue running the script after the user closes the page
set_time_limit(0); // Remove time limit for script execution
ini_set('display_errors', 1); // Display errors for debugging
error_reporting(E_ALL); // Report all types of errors
$apiKey = '6ed67a8f6e73fc1evtd2cc981d7c76316'; // Replace with your actual WHOIS API key
$dbHost = 'localhost';
$dbUsername = 'internet_wejai'; // Update with your actual database username
$dbPassword = 'Remya@158'; // Update with your actual database password
$dbName = 'internet_whoishistory'; // Your database name
// Create connection to MySQL database
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
if ($db->connect_error) {
die("Connection failed: " . $db->connect_error);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['file'])) {
if ($_FILES['file']['error'] == 0) {
$fileName = $_FILES['file']['tmp_name'];
$domains = file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($domains as $domain) {
echo "Processing domain: $domain<br>";
flush(); // Flush system output buffer
$url = "https://api.whoxy.com/?key=$apiKey&history=$domain&format=xml";
$xmlString = file_get_contents($url);
if ($xmlString === false) {
echo "Failed to retrieve data for $domain<br>";
continue;
}
$xml = simplexml_load_string($xmlString);
if (!$xml) {
echo "Failed to parse XML for $domain<br>";
continue;
}
if (isset($xml->whois_records) && $xml->total_records > 0) {
foreach ($xml->whois_records->whois_record as $record) {
$registrant = $record->registrant_contact;
if ($registrant) {
$fullName = (string)$registrant->full_name;
$emailAddress = (string)$registrant->email_address;
if ($fullName && $emailAddress) {
$stmt = $db->prepare("INSERT INTO domain_contacts (domain_name, full_name, email_address) VALUES (?, ?, ?)");
if ($stmt) {
$stmt->bind_param("sss", $domain, $fullName, $emailAddress);
$stmt->execute();
echo "Inserted data for $domain<br>";
} else {
echo "Failed to prepare statement for $domain<br>";
}
}
}
}
}
sleep(60); // Wait for 1 minute before processing next domain
}
echo "All data processing complete.";
} else {
echo "Error uploading file: " . $_FILES['file']['error'];
}
} else {
echo "No file uploaded or wrong request method.";
}
$db->close(); // Close the database connection
?>