diff --git a/document_history.php b/document_history.php
new file mode 100644
index 0000000..5681ca4
--- /dev/null
+++ b/document_history.php
@@ -0,0 +1,85 @@
+connect_error) {
+ die("Connection failed: " . $mysqli->connect_error);
+}
+
+// Buscar histórico de documentos processados
+$query = "SELECT pd.*, u.username FROM processed_documents pd
+ LEFT JOIN users u ON pd.user_id = u.id
+ ORDER BY pd.created_at DESC";
+$result = $mysqli->query($query);
+?>
+
+
+
Histórico de Documentos Processados
+
+
+
+
+ | Data/Hora |
+ Usuário |
+ Documento Original |
+ Documento Processado |
+ Ações |
+
+
+
+ fetch_assoc()): ?>
+
+ |
+ |
+
+
+ Ver Original
+
+ |
+
+
+ Ver Processado
+
+ |
+
+
+ |
+
+
+
+
+
+
+
diff --git a/document_processor.php b/document_processor.php
new file mode 100644
index 0000000..4df1ada
--- /dev/null
+++ b/document_processor.php
@@ -0,0 +1,139 @@
+outputPath = $outputPath;
+
+ // Detecta o tipo da imagem e carrega
+ $imageInfo = getimagesize($imagePath);
+ if ($imageInfo === false) {
+ throw new Exception('Failed to load image');
+ }
+
+ switch ($imageInfo[2]) {
+ case IMAGETYPE_JPEG:
+ $this->srcImage = imagecreatefromjpeg($imagePath);
+ break;
+ case IMAGETYPE_PNG:
+ $this->srcImage = imagecreatefrompng($imagePath);
+ break;
+ default:
+ throw new Exception('Unsupported image type');
+ }
+
+ if ($this->srcImage === false) {
+ throw new Exception('Failed to create image resource');
+ }
+
+ // Pipeline de processamento
+ $this->detectEdges()
+ ->autoRotate()
+ ->enhanceImage()
+ ->saveResult();
+
+ return $this->outputPath;
+ }
+
+ private function detectEdges() {
+ $width = imagesx($this->srcImage);
+ $height = imagesy($this->srcImage);
+
+ // Cria imagem temporária
+ $temp = imagecreatetruecolor($width, $height);
+ imagecopy($temp, $this->srcImage, 0, 0, 0, 0, $width, $height);
+
+ // Converte para escala de cinza
+ imagefilter($temp, IMG_FILTER_GRAYSCALE);
+
+ // Aplica detecção de bordas
+ imagefilter($temp, IMG_FILTER_EDGEDETECT);
+
+ $this->processedImage = $temp;
+ return $this;
+ }
+
+ private function autoRotate() {
+ if (!isset($this->processedImage)) {
+ $this->processedImage = $this->srcImage;
+ }
+
+ $width = imagesx($this->processedImage);
+ $height = imagesy($this->processedImage);
+
+ // Detecta ângulo baseado em bordas horizontais/verticais
+ $angle = $this->detectRotationAngle();
+
+ if ($angle != 0) {
+ $rotated = imagerotate($this->processedImage, $angle, 0);
+ if ($rotated !== false) {
+ $this->processedImage = $rotated;
+ }
+ }
+
+ return $this;
+ }
+
+ private function enhanceImage() {
+ if (!isset($this->processedImage)) {
+ $this->processedImage = $this->srcImage;
+ }
+
+ // Ajusta contraste
+ imagefilter($this->processedImage, IMG_FILTER_CONTRAST, -10);
+
+ // Ajusta brilho
+ imagefilter($this->processedImage, IMG_FILTER_BRIGHTNESS, 10);
+
+ // Ajusta nitidez
+ imagefilter($this->processedImage, IMG_FILTER_SMOOTH, -7);
+
+ // Ajusta saturação
+ imagefilter($this->processedImage, IMG_FILTER_COLORIZE, 0, 0, 0, 10);
+
+ return $this;
+ }
+
+ private function detectRotationAngle() {
+ // Implementação simplificada de detecção de ângulo
+ // Baseado na análise de bordas horizontais e verticais
+ return 0; // Por enquanto retorna 0 (sem rotação)
+ }
+
+ private function saveResult() {
+ if (!isset($this->processedImage)) {
+ throw new Exception('No processed image to save');
+ }
+
+ $extension = strtolower(pathinfo($this->outputPath, PATHINFO_EXTENSION));
+
+ switch ($extension) {
+ case 'jpg':
+ case 'jpeg':
+ imagejpeg($this->processedImage, $this->outputPath, 90);
+ break;
+ case 'png':
+ imagepng($this->processedImage, $this->outputPath, 9);
+ break;
+ default:
+ throw new Exception('Unsupported output image type');
+ }
+
+ if (is_resource($this->srcImage)) {
+ imagedestroy($this->srcImage);
+ }
+ if (is_resource($this->processedImage)) {
+ imagedestroy($this->processedImage);
+ }
+
+ return $this;
+ }
+}
diff --git a/index.php b/index.php
index 442e759..c089384 100644
--- a/index.php
+++ b/index.php
@@ -52,6 +52,10 @@ include 'top_menu.php';
include 'clientes/edit_note.php';
} elseif ($page == 'delete_note' && isset($_POST['id'])) {
include 'clientes/delete_note.php';
+ } elseif ($page == 'process_document') {
+ include 'process_document.php';
+ } elseif ($page == 'document_history') {
+ include 'document_history.php';
} else {
echo "Bem-vindo ao Sistema de Ferramentas
";
}
diff --git a/menu.php b/menu.php
index afd199e..4cd19d0 100644
--- a/menu.php
+++ b/menu.php
@@ -12,7 +12,7 @@ if (!isset($_SESSION['user_id'])) {
Autenticador de Provas Digitais
@@ -24,6 +24,13 @@ if (!isset($_SESSION['user_id'])) {
Listagem de Clientes
+
+ Processamento de Documentos
+
+
diff --git a/process_document.php b/process_document.php
new file mode 100644
index 0000000..0e93852
--- /dev/null
+++ b/process_document.php
@@ -0,0 +1,85 @@
+processDocument($uploadFile, $processedFile);
+
+ // Salva o registro no banco de dados
+ $mysqli = new mysqli("10.15.0.42", "root", "34641747", "valida");
+ $stmt = $mysqli->prepare("INSERT INTO processed_documents (user_id, original_path, processed_path, created_at) VALUES (?, ?, ?, NOW())");
+ $stmt->bind_param("iss", $_SESSION['user_id'], $uploadFile, $processedFile);
+ $stmt->execute();
+
+ $message = "Documento processado com sucesso!";
+ $success = true;
+ } else {
+ throw new Exception("Falha ao fazer upload do arquivo.");
+ }
+ } catch (Exception $e) {
+ $message = "Erro: " . $e->getMessage();
+ $success = false;
+ }
+}
+?>
+
+
+
Processamento de Documentos
+
+
+
+
+
+
+
+
+
+
+
+
Resultado:
+
+
+
Original:
+
; ?>)
+
+
+
Processado:
+
; ?>)
+
+
+
+
+
diff --git a/style.css b/style.css
index 4eb5acf..2723ee2 100644
--- a/style.css
+++ b/style.css
@@ -209,3 +209,50 @@ textarea {
#search-button:hover {
background-color: #0056b3;
}
+
+/* Estilos para processamento de documentos */
+.upload-form {
+ max-width: 600px;
+ margin: 20px auto;
+ padding: 20px;
+ background: #f5f5f5;
+ border-radius: 5px;
+}
+
+.result-preview {
+ margin-top: 30px;
+}
+
+.image-comparison {
+ display: flex;
+ justify-content: space-around;
+ margin-top: 20px;
+ flex-wrap: wrap;
+}
+
+.image-comparison img {
+ max-width: 45%;
+ height: auto;
+ margin: 10px;
+ border: 1px solid #ddd;
+ box-shadow: 0 0 5px rgba(0,0,0,0.2);
+}
+
+.alert {
+ padding: 15px;
+ margin-bottom: 20px;
+ border: 1px solid transparent;
+ border-radius: 4px;
+}
+
+.alert-success {
+ color: #155724;
+ background-color: #d4edda;
+ border-color: #c3e6cb;
+}
+
+.alert-error {
+ color: #721c24;
+ background-color: #f8d7da;
+ border-color: #f5c6cb;
+}