DNSBlock
This commit is contained in:
112
resources/views/admin/servers/form.php
Normal file
112
resources/views/admin/servers/form.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<div class="max-w-2xl mx-auto bg-white rounded-xl shadow-sm border border-gray-100 p-6">
|
||||
<h3 class="text-lg font-semibold text-gray-800 mb-6"><?= isset($server) ? 'Editar Servidor' : 'Novo Servidor' ?>
|
||||
</h3>
|
||||
|
||||
<?php if (isset($_SESSION['flash_error'])): ?>
|
||||
<div class="bg-red-50 text-red-700 p-4 rounded-lg mb-6">
|
||||
<?= $_SESSION['flash_error'];
|
||||
unset($_SESSION['flash_error']); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form action="<?= isset($server) ? '/admin/servers/update/' . $server['id'] : '/admin/servers/store' ?>"
|
||||
method="POST">
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Cliente</label>
|
||||
<select name="client_id"
|
||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"
|
||||
required>
|
||||
<option value="">Selecione um cliente...</option>
|
||||
<?php foreach ($clients as $client): ?>
|
||||
<option value="<?= $client['id'] ?>" <?= (isset($server) && $server['client_id'] == $client['id']) ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($client['name']) ?> (<?= htmlspecialchars($client['asn']) ?>)
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Nome do Servidor</label>
|
||||
<input type="text" name="name" value="<?= $server['name'] ?? '' ?>"
|
||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">IP v4</label>
|
||||
<input type="text" name="ip_v4" value="<?= $server['ip_v4'] ?? '' ?>"
|
||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"
|
||||
required placeholder="0.0.0.0">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">IP v6 (Opcional)</label>
|
||||
<input type="text" name="ip_v6" value="<?= $server['ip_v6'] ?? '' ?>"
|
||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent"
|
||||
placeholder="::1">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($server)): ?>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Status</label>
|
||||
<select name="status"
|
||||
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent">
|
||||
<option value="active" <?= $server['status'] == 'active' ? 'selected' : '' ?>>Ativo</option>
|
||||
<option value="inactive" <?= $server['status'] == 'inactive' ? 'selected' : '' ?>>Inativo</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-span-1 md:col-span-2 border-t border-gray-100 pt-4 mt-2">
|
||||
<h4 class="text-sm font-semibold text-gray-900 mb-4">Integração do Agente</h4>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Serial Key</label>
|
||||
<div class="flex">
|
||||
<input type="text" value="<?= $server['serial_key'] ?>" readonly
|
||||
class="w-full px-4 py-2 bg-gray-50 border border-gray-300 rounded-l-lg text-gray-500 font-mono text-sm">
|
||||
<button type="button"
|
||||
onclick="navigator.clipboard.writeText('<?= $server['serial_key'] ?>')"
|
||||
class="px-3 py-2 bg-gray-100 border border-l-0 border-gray-300 rounded-r-lg hover:bg-gray-200 text-gray-600">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3">
|
||||
</path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Machine ID Vinculado</label>
|
||||
<?php if (!empty($server['machine_id'])): ?>
|
||||
<div class="flex items-center space-x-2">
|
||||
<input type="text" value="<?= $server['machine_id'] ?>" readonly
|
||||
class="w-full px-4 py-2 bg-gray-50 border border-gray-300 rounded-lg text-gray-500 font-mono text-sm">
|
||||
<a href="/admin/servers/reset-machine/<?= $server['id'] ?>"
|
||||
onclick="return confirm('Tem certeza? Isso permitirá que um novo servidor utilize esta Serial Key.')"
|
||||
class="px-4 py-2 bg-red-100 text-red-700 rounded-lg hover:bg-red-200 text-sm whitespace-nowrap">
|
||||
Desvincular
|
||||
</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="px-4 py-2 bg-yellow-50 border border-yellow-100 rounded-lg text-yellow-700 text-sm">
|
||||
Nenhuma máquina vinculada. Aguardando conexão.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex justify-end space-x-3">
|
||||
<a href="/admin/servers"
|
||||
class="px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg transition-colors">Cancelar</a>
|
||||
<button type="submit"
|
||||
class="px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-700 transition-colors">
|
||||
<?= isset($server) ? 'Salvar Alterações' : 'Criar Servidor' ?>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
87
resources/views/admin/servers/index.php
Normal file
87
resources/views/admin/servers/index.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100 flex justify-between items-center bg-gray-50">
|
||||
<h3 class="text-lg font-semibold text-gray-800">Servidores Registrados</h3>
|
||||
<a href="/admin/servers/create"
|
||||
class="bg-primary-600 hover:bg-primary-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition-colors flex items-center">
|
||||
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
|
||||
</svg>
|
||||
Novo Servidor
|
||||
</a>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left border-collapse">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider bg-gray-50">Nome
|
||||
</th>
|
||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider bg-gray-50">Cliente
|
||||
</th>
|
||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider bg-gray-50">IP (v4)
|
||||
</th>
|
||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider bg-gray-50">Serial
|
||||
Key</th>
|
||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider bg-gray-50">Status
|
||||
</th>
|
||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider bg-gray-50">Agente
|
||||
</th>
|
||||
<th class="px-6 py-3 text-xs font-medium text-gray-500 uppercase tracking-wider bg-gray-50">Ações
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
<?php if (!empty($servers)): ?>
|
||||
<?php foreach ($servers as $server): ?>
|
||||
<?php
|
||||
$lastSeen = !empty($server['last_seen']) ? strtotime($server['last_seen']) : 0;
|
||||
$isOnline = $lastSeen && (time() - $lastSeen < 300); // 5 minutes
|
||||
$lastSeenText = $lastSeen ? date('d/m/Y H:i', $lastSeen) : 'Nunca';
|
||||
?>
|
||||
<tr class="hover:bg-gray-50 transition-colors">
|
||||
<td class="px-6 py-4 text-sm font-medium text-gray-900"><?= htmlspecialchars($server['name']) ?>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-gray-500"><?= htmlspecialchars($server['client_name']) ?></td>
|
||||
<td class="px-6 py-4 text-sm text-gray-500"><?= htmlspecialchars($server['ip_v4']) ?></td>
|
||||
<td class="px-6 py-4 text-sm text-gray-400 font-mono text-xs">
|
||||
<div class="flex items-center space-x-2">
|
||||
<span><?= substr($server['serial_key'], 0, 8) ?>...</span>
|
||||
<button
|
||||
onclick="navigator.clipboard.writeText('<?= $server['serial_key'] ?>'); alert('Key copiada!');"
|
||||
class="text-primary-600 hover:text-primary-800" title="Copiar Serial Completo">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z">
|
||||
</path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm">
|
||||
<span
|
||||
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full <?= $server['status'] == 'active' ? 'bg-green-100 text-green-800' : 'bg-gray-100 text-gray-800' ?>">
|
||||
<?= $server['status'] == 'active' ? 'Ativo' : 'Inativo' ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm">
|
||||
<span title="Visto por último: <?= $lastSeenText ?>"
|
||||
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full <?= $isOnline ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800' ?>">
|
||||
<?= $isOnline ? 'Online' : 'Offline' ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm font-medium">
|
||||
<a href="/admin/servers/edit/<?= $server['id'] ?>"
|
||||
class="text-[#1e3a8a] hover:text-blue-900 mr-3">Editar</a>
|
||||
<a href="/admin/servers/delete/<?= $server['id'] ?>" class="text-red-600 hover:text-red-900"
|
||||
onclick="return confirm('Tem certeza?')">Excluir</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="6" class="px-6 py-4 text-center text-gray-500">Nenhum servidor encontrado.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user