|
Server IP : 217.21.85.138 / Your IP : 216.73.216.103 Web Server : LiteSpeed System : Linux in-mum-web906.main-hosting.eu 4.18.0-553.37.1.lve.el8.x86_64 #1 SMP Mon Feb 10 22:45:17 UTC 2025 x86_64 User : u915722082 ( 915722082) PHP Version : 7.4.33 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u915722082/public_html/globalmining/../pms/admin/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
session_start();
if (!isset($_SESSION['admin_id'])) {
header("Location: login.php");
exit;
}
require_once '../config/config.php';
function fetchDomainsFromAPI() {
$api_token = HOSTINGER_API_TOKEN;
$api_url = 'https://developers.hostinger.com/api/domains/v1/portfolio';
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $api_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $api_token,
'Content-Type: application/json',
'Accept: application/json'
],
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => true
]);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($http_code === 200) {
$data = json_decode($response, true);
return $data['data'] ?? $data['domains'] ?? $data ?? [];
}
return [];
}
$domains = fetchDomainsFromAPI();
// Set headers for CSV download
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=domains_export_' . date('Y-m-d') . '.csv');
// Create output stream
$output = fopen('php://output', 'w');
// Add CSV headers
fputcsv($output, ['#', 'Domain Name', 'Expiry Date', 'Days Remaining', 'Status', 'Priority']);
// Sort by expiry date
usort($domains, function($a, $b) {
$dateA = strtotime($a['expiry_date'] ?? $a['expires_at'] ?? '9999-12-31');
$dateB = strtotime($b['expiry_date'] ?? $b['expires_at'] ?? '9999-12-31');
return $dateA - $dateB;
});
// Add domain data
foreach ($domains as $index => $domain) {
$domain_name = $domain['domain'] ?? $domain['name'] ?? 'N/A';
$expiry_date = $domain['expiry_date'] ?? $domain['expires_at'] ?? 'N/A';
$status = $domain['status'] ?? 'active';
$days_remaining = 'N/A';
$priority = 'Normal';
if ($expiry_date !== 'N/A') {
$days = floor((strtotime($expiry_date) - time()) / (60 * 60 * 24));
$days_remaining = $days;
if ($days < 0) {
$priority = 'Expired';
} elseif ($days <= 7) {
$priority = 'Critical';
} elseif ($days <= 30) {
$priority = 'Warning';
}
}
fputcsv($output, [
$index + 1,
$domain_name,
$expiry_date,
$days_remaining,
ucfirst($status),
$priority
]);
}
fclose($output);
exit;
?>