T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/domains/lavocat.quebec/private_html/php-migration/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/lavocat.quebec/private_html/php-migration/models/LegalCase.php
<?php
/**
 * LegalCase Model
 * Migrated from Prisma LegalCase model
 */

require_once __DIR__ . '/../config/database.php';

class LegalCase {
    private $conn;
    private $table_name = "legal_cases";

    public $id;
    public $title;
    public $description;
    public $status;
    public $priority;
    public $category;
    public $clientId;
    public $leadLawyerId;
    public $lawFirmId;
    public $createdAt;
    public $updatedAt;
    public $dueDate;
    public $estimatedHours;
    public $actualHours;
    public $hourlyRate;
    public $totalCost;
    public $caseNumber;
    public $court;
    public $judge;
    public $opposingParty;
    public $opposingLawyer;
    public $caseType;
    public $jurisdiction;
    public $filingDate;
    public $hearingDate;
    public $settlementAmount;
    public $outcome;
    public $notes;
    public $documents;
    public $tags;
    public $isPublic;
    public $isArchived;

    public function __construct($db) {
        $this->conn = $db;
    }

    // Create case
    public function create() {
        $query = "INSERT INTO " . $this->table_name . " 
                  (id, title, description, status, priority, category, clientId, leadLawyerId, lawFirmId, 
                   createdAt, updatedAt, dueDate, estimatedHours, actualHours, hourlyRate, totalCost, 
                   caseNumber, court, judge, opposingParty, opposingLawyer, caseType, jurisdiction, 
                   filingDate, hearingDate, settlementAmount, outcome, notes, documents, tags, 
                   isPublic, isArchived)
                  VALUES 
                  (:id, :title, :description, :status, :priority, :category, :clientId, :leadLawyerId, :lawFirmId, 
                   :createdAt, :updatedAt, :dueDate, :estimatedHours, :actualHours, :hourlyRate, :totalCost, 
                   :caseNumber, :court, :judge, :opposingParty, :opposingLawyer, :caseType, :jurisdiction, 
                   :filingDate, :hearingDate, :settlementAmount, :outcome, :notes, :documents, :tags, 
                   :isPublic, :isArchived)";

        $stmt = $this->conn->prepare($query);

        // Generate UUID for id
        $this->id = $this->generateUUID();
        $this->createdAt = date('Y-m-d H:i:s');
        $this->updatedAt = date('Y-m-d H:i:s');

        // Convert arrays to JSON
        $this->documents = is_array($this->documents) ? json_encode($this->documents) : $this->documents;
        $this->tags = is_array($this->tags) ? json_encode($this->tags) : $this->tags;

        // Bind values
        $stmt->bindParam(':id', $this->id);
        $stmt->bindParam(':title', $this->title);
        $stmt->bindParam(':description', $this->description);
        $stmt->bindParam(':status', $this->status);
        $stmt->bindParam(':priority', $this->priority);
        $stmt->bindParam(':category', $this->category);
        $stmt->bindParam(':clientId', $this->clientId);
        $stmt->bindParam(':leadLawyerId', $this->leadLawyerId);
        $stmt->bindParam(':lawFirmId', $this->lawFirmId);
        $stmt->bindParam(':createdAt', $this->createdAt);
        $stmt->bindParam(':updatedAt', $this->updatedAt);
        $stmt->bindParam(':dueDate', $this->dueDate);
        $stmt->bindParam(':estimatedHours', $this->estimatedHours);
        $stmt->bindParam(':actualHours', $this->actualHours);
        $stmt->bindParam(':hourlyRate', $this->hourlyRate);
        $stmt->bindParam(':totalCost', $this->totalCost);
        $stmt->bindParam(':caseNumber', $this->caseNumber);
        $stmt->bindParam(':court', $this->court);
        $stmt->bindParam(':judge', $this->judge);
        $stmt->bindParam(':opposingParty', $this->opposingParty);
        $stmt->bindParam(':opposingLawyer', $this->opposingLawyer);
        $stmt->bindParam(':caseType', $this->caseType);
        $stmt->bindParam(':jurisdiction', $this->jurisdiction);
        $stmt->bindParam(':filingDate', $this->filingDate);
        $stmt->bindParam(':hearingDate', $this->hearingDate);
        $stmt->bindParam(':settlementAmount', $this->settlementAmount);
        $stmt->bindParam(':outcome', $this->outcome);
        $stmt->bindParam(':notes', $this->notes);
        $stmt->bindParam(':documents', $this->documents);
        $stmt->bindParam(':tags', $this->tags);
        $stmt->bindParam(':isPublic', $this->isPublic);
        $stmt->bindParam(':isArchived', $this->isArchived);

        if($stmt->execute()) {
            return true;
        }
        return false;
    }

    // Read case by ID
    public function findById($id) {
        $query = "SELECT * FROM " . $this->table_name . " WHERE id = :id LIMIT 1";
        $stmt = $this->conn->prepare($query);
        $stmt->bindParam(':id', $id);
        $stmt->execute();

        if($stmt->rowCount() > 0) {
            $row = $stmt->fetch(PDO::FETCH_ASSOC);
            $this->id = $row['id'];
            $this->title = $row['title'];
            $this->description = $row['description'];
            $this->status = $row['status'];
            $this->priority = $row['priority'];
            $this->category = $row['category'];
            $this->clientId = $row['clientId'];
            $this->leadLawyerId = $row['leadLawyerId'];
            $this->lawFirmId = $row['lawFirmId'];
            $this->createdAt = $row['createdAt'];
            $this->updatedAt = $row['updatedAt'];
            $this->dueDate = $row['dueDate'];
            $this->estimatedHours = $row['estimatedHours'];
            $this->actualHours = $row['actualHours'];
            $this->hourlyRate = $row['hourlyRate'];
            $this->totalCost = $row['totalCost'];
            $this->caseNumber = $row['caseNumber'];
            $this->court = $row['court'];
            $this->judge = $row['judge'];
            $this->opposingParty = $row['opposingParty'];
            $this->opposingLawyer = $row['opposingLawyer'];
            $this->caseType = $row['caseType'];
            $this->jurisdiction = $row['jurisdiction'];
            $this->filingDate = $row['filingDate'];
            $this->hearingDate = $row['hearingDate'];
            $this->settlementAmount = $row['settlementAmount'];
            $this->outcome = $row['outcome'];
            $this->notes = $row['notes'];
            $this->documents = json_decode($row['documents'], true);
            $this->tags = json_decode($row['tags'], true);
            $this->isPublic = $row['isPublic'];
            $this->isArchived = $row['isArchived'];
            return true;
        }
        return false;
    }

    // Get cases by client ID
    public function getByClientId($clientId, $page = 1, $limit = 10) {
        $offset = ($page - 1) * $limit;
        $query = "SELECT * FROM " . $this->table_name . " 
                  WHERE clientId = :clientId AND isArchived = 0 
                  ORDER BY createdAt DESC LIMIT :limit OFFSET :offset";
        $stmt = $this->conn->prepare($query);
        $stmt->bindParam(':clientId', $clientId);
        $stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
        $stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
        $stmt->execute();

        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    // Get cases by lawyer ID
    public function getByLawyerId($leadLawyerId, $page = 1, $limit = 10) {
        $offset = ($page - 1) * $limit;
        $query = "SELECT * FROM " . $this->table_name . " 
                  WHERE leadLawyerId = :leadLawyerId AND isArchived = 0 
                  ORDER BY createdAt DESC LIMIT :limit OFFSET :offset";
        $stmt = $this->conn->prepare($query);
        $stmt->bindParam(':leadLawyerId', $leadLawyerId);
        $stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
        $stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
        $stmt->execute();

        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    // Get public cases
    public function getPublicCases($page = 1, $limit = 10, $filters = []) {
        $offset = ($page - 1) * $limit;
        $whereClause = "WHERE isPublic = 1 AND isArchived = 0";
        $params = [];

        // Apply filters
        if (!empty($filters['category'])) {
            $whereClause .= " AND category = :category";
            $params[':category'] = $filters['category'];
        }
        if (!empty($filters['status'])) {
            $whereClause .= " AND status = :status";
            $params[':status'] = $filters['status'];
        }
        if (!empty($filters['search'])) {
            $whereClause .= " AND (title LIKE :search OR description LIKE :search)";
            $params[':search'] = '%' . $filters['search'] . '%';
        }

        $query = "SELECT * FROM " . $this->table_name . " " . $whereClause . " ORDER BY createdAt DESC LIMIT :limit OFFSET :offset";
        $stmt = $this->conn->prepare($query);
        
        foreach ($params as $key => $value) {
            $stmt->bindValue($key, $value);
        }
        $stmt->bindValue(':limit', $limit, PDO::PARAM_INT);
        $stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
        $stmt->execute();

        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    // Update case
    public function update() {
        $query = "UPDATE " . $this->table_name . " 
                  SET title = :title, 
                      description = :description,
                      status = :status,
                      priority = :priority,
                      category = :category,
                      leadLawyerId = :leadLawyerId,
                      lawFirmId = :lawFirmId,
                      updatedAt = :updatedAt,
                      dueDate = :dueDate,
                      estimatedHours = :estimatedHours,
                      actualHours = :actualHours,
                      hourlyRate = :hourlyRate,
                      totalCost = :totalCost,
                      caseNumber = :caseNumber,
                      court = :court,
                      judge = :judge,
                      opposingParty = :opposingParty,
                      opposingLawyer = :opposingLawyer,
                      caseType = :caseType,
                      jurisdiction = :jurisdiction,
                      filingDate = :filingDate,
                      hearingDate = :hearingDate,
                      settlementAmount = :settlementAmount,
                      outcome = :outcome,
                      notes = :notes,
                      documents = :documents,
                      tags = :tags,
                      isPublic = :isPublic,
                      isArchived = :isArchived
                  WHERE id = :id";

        $stmt = $this->conn->prepare($query);

        $this->updatedAt = date('Y-m-d H:i:s');

        // Convert arrays to JSON
        $this->documents = is_array($this->documents) ? json_encode($this->documents) : $this->documents;
        $this->tags = is_array($this->tags) ? json_encode($this->tags) : $this->tags;

        // Bind values
        $stmt->bindParam(':id', $this->id);
        $stmt->bindParam(':title', $this->title);
        $stmt->bindParam(':description', $this->description);
        $stmt->bindParam(':status', $this->status);
        $stmt->bindParam(':priority', $this->priority);
        $stmt->bindParam(':category', $this->category);
        $stmt->bindParam(':leadLawyerId', $this->leadLawyerId);
        $stmt->bindParam(':lawFirmId', $this->lawFirmId);
        $stmt->bindParam(':updatedAt', $this->updatedAt);
        $stmt->bindParam(':dueDate', $this->dueDate);
        $stmt->bindParam(':estimatedHours', $this->estimatedHours);
        $stmt->bindParam(':actualHours', $this->actualHours);
        $stmt->bindParam(':hourlyRate', $this->hourlyRate);
        $stmt->bindParam(':totalCost', $this->totalCost);
        $stmt->bindParam(':caseNumber', $this->caseNumber);
        $stmt->bindParam(':court', $this->court);
        $stmt->bindParam(':judge', $this->judge);
        $stmt->bindParam(':opposingParty', $this->opposingParty);
        $stmt->bindParam(':opposingLawyer', $this->opposingLawyer);
        $stmt->bindParam(':caseType', $this->caseType);
        $stmt->bindParam(':jurisdiction', $this->jurisdiction);
        $stmt->bindParam(':filingDate', $this->filingDate);
        $stmt->bindParam(':hearingDate', $this->hearingDate);
        $stmt->bindParam(':settlementAmount', $this->settlementAmount);
        $stmt->bindParam(':outcome', $this->outcome);
        $stmt->bindParam(':notes', $this->notes);
        $stmt->bindParam(':documents', $this->documents);
        $stmt->bindParam(':tags', $this->tags);
        $stmt->bindParam(':isPublic', $this->isPublic);
        $stmt->bindParam(':isArchived', $this->isArchived);

        if($stmt->execute()) {
            return true;
        }
        return false;
    }

    // Delete case
    public function delete() {
        $query = "DELETE FROM " . $this->table_name . " WHERE id = :id";
        $stmt = $this->conn->prepare($query);
        $stmt->bindParam(':id', $this->id);

        if($stmt->execute()) {
            return true;
        }
        return false;
    }

    // Archive case
    public function archive() {
        $this->isArchived = 1;
        return $this->update();
    }

    // Count cases
    public function count($filters = []) {
        $whereClause = "WHERE 1=1";
        $params = [];

        // Apply filters
        if (!empty($filters['clientId'])) {
            $whereClause .= " AND clientId = :clientId";
            $params[':clientId'] = $filters['clientId'];
        }
        if (!empty($filters['leadLawyerId'])) {
            $whereClause .= " AND leadLawyerId = :leadLawyerId";
            $params[':leadLawyerId'] = $filters['leadLawyerId'];
        }
        if (!empty($filters['status'])) {
            $whereClause .= " AND status = :status";
            $params[':status'] = $filters['status'];
        }
        if (!empty($filters['isPublic'])) {
            $whereClause .= " AND isPublic = :isPublic";
            $params[':isPublic'] = $filters['isPublic'];
        }
        if (!empty($filters['isArchived'])) {
            $whereClause .= " AND isArchived = :isArchived";
            $params[':isArchived'] = $filters['isArchived'];
        }

        $query = "SELECT COUNT(*) as total FROM " . $this->table_name . " " . $whereClause;
        $stmt = $this->conn->prepare($query);
        
        foreach ($params as $key => $value) {
            $stmt->bindValue($key, $value);
        }
        $stmt->execute();

        $row = $stmt->fetch(PDO::FETCH_ASSOC);
        return $row['total'];
    }

    // Generate UUID
    private function generateUUID() {
        return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            mt_rand(0, 0xffff), mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0x0fff) | 0x4000,
            mt_rand(0, 0x3fff) | 0x8000,
            mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
        );
    }
}
?>

CasperSecurity Mini