|
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/rasi/../projects/config/../admin/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
session_start();
if (!isset($_SESSION['admin_id'])) {
header("Location: login.php");
exit;
}
require_once '../config/config.php';
$con = getDatabaseConnection();
$current_user_role = $_SESSION['role'] ?? 'Manager';
$current_user_id = $_SESSION['admin_id'];
$current_user_name = $_SESSION['user_name'] ?? 'Admin';
// Fetch domains from Hostinger API
function fetchDomainsFromAPI() {
$api_token = HOSTINGER_API_TOKEN; // Define this in config.php
$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();
// Calculate statistics
$total_domains = count($domains);
$active_domains = 0;
$expiring_soon = 0;
$expired_domains = 0;
foreach ($domains as $domain) {
$expiry_date = $domain['expiry_date'] ?? $domain['expires_at'] ?? null;
if ($expiry_date) {
$days_remaining = floor((strtotime($expiry_date) - time()) / (60 * 60 * 24));
if ($days_remaining < 0) {
$expired_domains++;
} elseif ($days_remaining <= 30) {
$expiring_soon++;
} else {
$active_domains++;
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="../" />
<title>Domain Portfolio - TDS Admin Hub</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700" />
<link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style.bundle.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.datatables.net/1.13.7/css/dataTables.bootstrap5.min.css" rel="stylesheet" type="text/css" />
</head>
<body id="kt_app_body" data-kt-app-layout="dark-sidebar" data-kt-app-header-fixed="true"
data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="true"
data-kt-app-sidebar-hoverable="true" data-kt-app-sidebar-push-header="true"
data-kt-app-sidebar-push-toolbar="true" data-kt-app-sidebar-push-footer="true"
data-kt-app-toolbar-enabled="true" class="app-default">
<script>
var defaultThemeMode = "light";
var themeMode;
if (document.documentElement) {
if (document.documentElement.hasAttribute("data-bs-theme-mode")) {
themeMode = document.documentElement.getAttribute("data-bs-theme-mode");
} else {
if (localStorage.getItem("data-bs-theme") !== null) {
themeMode = localStorage.getItem("data-bs-theme");
} else {
themeMode = defaultThemeMode;
}
}
if (themeMode === "system") {
themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
document.documentElement.setAttribute("data-bs-theme", themeMode);
}
</script>
<div class="d-flex flex-column flex-root app-root" id="kt_app_root">
<div class="app-page flex-column flex-column-fluid" id="kt_app_page">
<?php include 'includes/header.php'; ?>
<div class="app-wrapper flex-column flex-row-fluid" id="kt_app_wrapper">
<?php include 'includes/sidebar.php'; ?>
<div class="app-main flex-column flex-row-fluid" id="kt_app_main">
<div class="d-flex flex-column flex-column-fluid">
<div id="kt_app_toolbar" class="app-toolbar py-3 py-lg-6">
<div id="kt_app_toolbar_container" class="app-container container-xxl d-flex flex-stack">
<div class="page-title d-flex flex-column justify-content-center flex-wrap me-3">
<h1 class="page-heading d-flex text-gray-900 fw-bold fs-3 flex-column my-0">
🌐 Domain Portfolio Manager
</h1>
<ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1">
<li class="breadcrumb-item text-muted">
<a href="admin/dashboard.php" class="text-muted text-hover-primary">Home</a>
</li>
<li class="breadcrumb-item">
<span class="bullet bg-gray-500 w-5px h-2px"></span>
</li>
<li class="breadcrumb-item text-muted">Domains</li>
</ul>
</div>
</div>
</div>
<div id="kt_app_content" class="app-content flex-column-fluid">
<div id="kt_app_content_container" class="app-container container-xxl">
<!-- Domains Table -->
<div class="card">
<div class="card-header border-0 pt-6">
<div class="card-title">
<div class="d-flex align-items-center position-relative my-1">
<i class="ki-duotone ki-magnifier fs-3 position-absolute ms-5">
<span class="path1"></span>
<span class="path2"></span>
</i>
<input type="text" id="searchDomain"
class="form-control form-control-solid w-250px ps-13"
placeholder="Search domains..." />
</div>
</div>
<div class="card-toolbar">
<button type="button" class="btn btn-sm btn-primary" onclick="exportToCSV()">
<i class="ki-duotone ki-exit-down fs-3">
<span class="path1"></span>
<span class="path2"></span>
</i>
Export CSV
</button>
</div>
</div>
<div class="card-body py-4">
<div class="table-responsive">
<table class="table align-middle table-row-dashed fs-6 gy-5" id="domainsTable">
<thead>
<tr class="text-start text-muted fw-bold fs-7 text-uppercase gs-0">
<th class="min-w-50px">S.No</th>
<th class="min-w-200px">Domain Name</th>
<th class="min-w-125px">Purchase Date</th>
<th class="min-w-125px">Expiry Date</th>
<th class="min-w-125px">Days Remaining</th>
<th class="min-w-150px">Status</th>
</tr>
</thead>
<tbody class="text-gray-600 fw-semibold">
<?php
// Sort by days remaining (closest to expiry first)
usort($domains, function($a, $b) {
$expiryA = $a['expiry_date'] ?? $a['expires_at'] ?? '9999-12-31';
$expiryB = $b['expiry_date'] ?? $b['expires_at'] ?? '9999-12-31';
$daysA = floor((strtotime($expiryA) - time()) / (60 * 60 * 24));
$daysB = floor((strtotime($expiryB) - time()) / (60 * 60 * 24));
return $daysA - $daysB;
});
foreach ($domains as $index => $domain):
$domain_name = $domain['domain'] ?? $domain['name'] ?? 'N/A';
$expiry_date = $domain['expiry_date'] ?? $domain['expires_at'] ?? null;
$purchase_date = $domain['created_at'] ?? $domain['purchase_date'] ?? $domain['registered_at'] ?? null;
$days_remaining = 'N/A';
$days_numeric = 9999; // For sorting
$badge_class = 'success';
$status_text = 'Active';
$priority_text = 'Normal';
if ($expiry_date) {
$days = floor((strtotime($expiry_date) - time()) / (60 * 60 * 24));
$days_numeric = $days;
if ($days < 0) {
$days_remaining = abs($days) . ' days ago';
$badge_class = 'danger';
$status_text = 'Expired';
$priority_text = 'Expired';
} elseif ($days <= 7) {
$days_remaining = $days . ' days';
$badge_class = 'danger';
$status_text = 'Active';
$priority_text = 'Critical';
} elseif ($days <= 30) {
$days_remaining = $days . ' days';
$badge_class = 'warning';
$status_text = 'Active';
$priority_text = 'Warning';
} else {
$days_remaining = $days . ' days';
$badge_class = 'success';
$status_text = 'Active';
$priority_text = 'Normal';
}
}
$formatted_expiry = $expiry_date ? date('M d, Y', strtotime($expiry_date)) : 'N/A';
$formatted_purchase = $purchase_date ? date('M d, Y', strtotime($purchase_date)) : 'N/A';
?>
<tr data-days="<?php echo $days_numeric; ?>">
<td class="sno-cell"><?php echo $index + 1; ?></td>
<td>
<div class="d-flex align-items-center">
<div class="symbol symbol-circle symbol-40px overflow-hidden me-3">
<div class="symbol-label">
<i class="ki-duotone ki-abstract-26 fs-2x text-primary">
<span class="path1"></span>
<span class="path2"></span>
</i>
</div>
</div>
<div class="d-flex flex-column">
<span class="text-gray-800 fw-bold">
<?php echo htmlspecialchars($domain_name); ?>
</span>
</div>
</div>
</td>
<td><?php echo $formatted_purchase; ?></td>
<td><?php echo $formatted_expiry; ?></td>
<td data-order="<?php echo $days_numeric; ?>"><?php echo $days_remaining; ?></td>
<td>
<span class="badge badge-light-<?php echo $badge_class; ?> me-2"><?php echo $status_text; ?></span>
<span class="badge badge-<?php echo $badge_class; ?>"><?php echo $priority_text; ?></span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include 'includes/footer.php'; ?>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="assets/plugins/global/plugins.bundle.js"></script>
<script src="assets/js/scripts.bundle.js"></script>
<script src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.7/js/dataTables.bootstrap5.min.js"></script>
<script>
var table;
$(document).ready(function() {
table = $('#domainsTable').DataTable({
responsive: true,
pageLength: 10,
lengthChange: false,
searching: true,
order: [[4, 'asc']], // Sort by Days Remaining
columnDefs: [
{
targets: 0, // S.No column
orderable: false, // Disable sorting on S.No
searchable: false
}
],
drawCallback: function(settings) {
// Update S.No after each draw (pagination, search, etc)
var api = this.api();
var startIndex = api.context[0]._iDisplayStart;
api.column(0, {page: 'current'}).nodes().each(function(cell, i) {
cell.innerHTML = startIndex + i + 1;
});
},
language: {
info: "Showing _START_ to _END_ of _TOTAL_ domains",
infoEmpty: "No domains available",
paginate: {
first: 'First',
previous: 'Previous',
next: 'Next',
last: 'Last'
}
}
});
// Hide default DataTables search
$('.dataTables_filter').hide();
// Connect custom search to DataTables
$('#searchDomain').on('keyup', function() {
table.search(this.value).draw();
});
});
function exportToCSV() {
window.location.href = 'admin/export_domains.php';
}
</script>
<?php include 'includes/chat_widget.php'; ?>
</body>
</html>