Tul xxx Tul
User / IP
:
216.73.217.33
Host / Server
:
45.84.207.204 / aircan.me
System
:
Linux lt-bnk-web1726.main-hosting.eu 5.14.0-611.36.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 3 11:23:52 EST 2026 x86_64
Command
|
Upload
|
Create
Mass Deface
|
Jumping
|
Symlink
|
Reverse Shell
Ping
|
Port Scan
|
DNS Lookup
|
Whois
|
Header
|
cURL
:
/
home
/
u931257429
/
domains
/
emprendo.com.co
/
invitados
/
siscaps
/
scripts
/
Viewing: seed.php
<?php declare(strict_types=1); // Seeder para insertar roles base y usuario administrador // Uso (desde el directorio del proyecto SISCAPS): // php sistema-agua/scripts/seed.php date_default_timezone_set('America/Mexico_City'); require __DIR__ . '/../config/database.php'; $pdo = (new Database())->getConnection(); if (!$pdo) { echo "No se pudo obtener conexión a la base de datos.\n"; exit(1); } function tableExists(PDO $pdo, string $table): bool { try { $pdo->query("SELECT 1 FROM `{$table}` LIMIT 1"); return true; } catch (Throwable $e) { return false; } } if (!tableExists($pdo, 'roles') || !tableExists($pdo, 'users')) { echo "Debes importar primero el esquema SQL: 'sistema-agua/Base de Datos/sistema_agua.sql'\n"; exit(1); } try { $pdo->beginTransaction(); // Insertar/actualizar roles base $roles = [ ['ADMIN', 'Administrador del sistema'], ['CAJERO', 'Gestión de facturas y pagos'], ['CLIENTE', 'Acceso al portal de cliente'], ['LECTOR', 'Registro de lecturas'], ]; $roleUpsert = $pdo->prepare( "INSERT INTO roles (name, description) VALUES (?, ?)\n ON DUPLICATE KEY UPDATE description = VALUES(description)" ); foreach ($roles as [$name, $desc]) { $roleUpsert->execute([$name, $desc]); } // Obtener id del rol ADMIN $stmt = $pdo->prepare("SELECT id FROM roles WHERE name = ? LIMIT 1"); $stmt->execute(['ADMIN']); $adminRoleId = (int)($stmt->fetchColumn() ?: 0); if ($adminRoleId <= 0) { throw new RuntimeException('No se pudo obtener role_id para ADMIN'); } // Helper para crear usuario si no existe $createUserIfMissing = function(string $username, string $email, string $first, string $last, string $password, int $roleId) use ($pdo): void { $q = $pdo->prepare('SELECT id FROM users WHERE email = ? LIMIT 1'); $q->execute([$email]); if ($q->fetchColumn()) { echo "Usuario ya existe (email: {$email}).\n"; return; } $hash = password_hash($password, PASSWORD_DEFAULT); $ins = $pdo->prepare('INSERT INTO users (username, email, password_hash, first_name, last_name, role_id, is_active, created_at) VALUES (:username, :email, :password_hash, :first_name, :last_name, :role_id, 1, NOW())'); $ins->execute([ ':username' => $username, ':email' => $email, ':password_hash' => $hash, ':first_name' => $first, ':last_name' => $last, ':role_id' => $roleId, ]); echo "Usuario creado: {$email} (usuario: {$username}).\n"; }; // Crear usuario admin $createUserIfMissing('admin', 'admin@siscaps.local', 'Admin', 'Root', 'Admin123!', $adminRoleId); // Obtener id del rol CAJERO $stmt = $pdo->prepare("SELECT id FROM roles WHERE name = ? LIMIT 1"); $stmt->execute(['CAJERO']); $cajeroRoleId = (int)($stmt->fetchColumn() ?: 0); if ($cajeroRoleId <= 0) { throw new RuntimeException('No se pudo obtener role_id para CAJERO'); } // Crear usuario cajero $createUserIfMissing('cajero', 'cajero@siscaps.local', 'Caja', 'Principal', 'Cajero123!', $cajeroRoleId); // Obtener id del rol CLIENTE $stmt->execute(['CLIENTE']); $clienteRoleId = (int)($stmt->fetchColumn() ?: 0); if ($clienteRoleId <= 0) { throw new RuntimeException('No se pudo obtener role_id para CLIENTE'); } // Crear usuario cliente $createUserIfMissing('cliente', 'cliente@siscaps.local', 'Juan', 'Cliente', 'Cliente123!', $clienteRoleId); $pdo->commit(); echo "Seeder completado.\n"; } catch (Throwable $e) { if ($pdo->inTransaction()) { $pdo->rollBack(); } echo "Error en seed: " . $e->getMessage() . "\n"; exit(1); }
Coded With 💗 by
0x6ick