Enhance DNS discovery, validation & transfers
Add comprehensive DNS management and input validation, plus safer transfer and logging behavior. - Add CronHelper utilities for cron scripts and unify logging/formatting. - Improve InputValidator: sanitizeDomainInput and validateRootDomain (handles multi-level TLDs) and use throughout domain import/create flows to reject subdomains. - DomainController: refactor DNS refresh to support quick/deep discovery (background deep scans), add endpoints to discover, add/delete/bulk-delete DNS records, import BIND zone files, enrich IP metadata via enrichIpDetails, and strengthen bulk import/reporting messages. - DnsRecord model: add source column handling (discovered/manual/imported), avoid auto-deleting manual/imported records, and add helpers for deleting, bulk deleting, manual adding and importing zone records. - Tag, NotificationGroup and Domain transfer logic: unlink groups when ownership changes, remove tags that belong to other users, add audit logging via Logger and improved bulk transfer reporting. TagController/View: show transferable users for admins and skip global tags on transfer. - Notification channels (Discord, Mattermost, etc.) and EmailHelper: allow explicit subjects and improve payload fields based on notification type. - Add new migration 029_add_dns_record_source.sql and wire it into the installer; update migrations detection. - Add new views/partials for confirm/import/transfer modals, update various domain/group/tag templates, and update cron scripts and routes for discovery. These changes preserve manual/imported DNS records, improve root-domain validation, enable background deep discovery, and add better logging/audit trails for transfers and imports.
This commit is contained in:
@@ -23,6 +23,7 @@ use App\Models\User;
|
||||
use App\Services\WhoisService;
|
||||
use App\Services\NotificationService;
|
||||
use App\Services\UpdateService;
|
||||
use App\Helpers\CronHelper;
|
||||
use Core\Database;
|
||||
|
||||
// Load environment variables
|
||||
@@ -56,27 +57,11 @@ try {
|
||||
|
||||
// Log file
|
||||
$logFile = __DIR__ . '/../logs/cron.log';
|
||||
$cron = new CronHelper($logFile);
|
||||
|
||||
function logMessage(string $message) {
|
||||
global $logFile;
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
file_put_contents($logFile, "[$timestamp] $message\n", FILE_APPEND);
|
||||
echo "[$timestamp] $message\n";
|
||||
}
|
||||
|
||||
function formatElapsedTime(float $seconds): string {
|
||||
if ($seconds < 60) {
|
||||
return sprintf("%.2f seconds", $seconds);
|
||||
} elseif ($seconds < 3600) {
|
||||
$minutes = floor($seconds / 60);
|
||||
$remainingSeconds = $seconds - ($minutes * 60);
|
||||
return sprintf("%d minute%s %.2f seconds", $minutes, $minutes != 1 ? 's' : '', $remainingSeconds);
|
||||
} else {
|
||||
$hours = floor($seconds / 3600);
|
||||
$remainingMinutes = floor(($seconds - ($hours * 3600)) / 60);
|
||||
$remainingSeconds = $seconds - ($hours * 3600) - ($remainingMinutes * 60);
|
||||
return sprintf("%d hour%s %d minute%s %.2f seconds", $hours, $hours != 1 ? 's' : '', $remainingMinutes, $remainingMinutes != 1 ? 's' : '', $remainingSeconds);
|
||||
}
|
||||
function logMessage(string $message): void {
|
||||
global $cron;
|
||||
$cron->log($message);
|
||||
}
|
||||
|
||||
// Record start time
|
||||
@@ -806,7 +791,7 @@ $settingModel->updateLastCheckRun();
|
||||
// Calculate elapsed time
|
||||
$endTime = microtime(true);
|
||||
$elapsedTime = $endTime - $startTime;
|
||||
$formattedTime = formatElapsedTime($elapsedTime);
|
||||
$formattedTime = CronHelper::formatElapsedTime($elapsedTime);
|
||||
|
||||
// Summary
|
||||
logMessage("\n=== Cron job completed ===");
|
||||
|
||||
Reference in New Issue
Block a user