-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from comatic0/develop
v5.1.0
- Loading branch information
Showing
28 changed files
with
565 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
require_once __DIR__ . '/../models/Mapa.php'; | ||
require_once __DIR__ . '/../includes/db.php'; | ||
|
||
class MapaController { | ||
private $mapaModel; | ||
public function __construct($pdo) { | ||
$this->mapaModel = new Mapa($pdo); | ||
} | ||
public function upload($nome, $imagem, $tipo) { | ||
$user_id = $_SESSION['user_id'] ?? null; | ||
if ($user_id) { | ||
$imageName = null; | ||
if (isset($imagem) && $imagem['error'] == UPLOAD_ERR_OK) { | ||
$imageTmpName = $imagem['tmp_name']; | ||
$imageName = uniqid() . '-' . basename($imagem['name']); // Gera um nome único | ||
$uploadDir = __DIR__ . '/../assets/mapas/'; | ||
|
||
// Move o arquivo para o diretório de uploads | ||
if (move_uploaded_file($imageTmpName, $uploadDir . $imageName)) { | ||
// A imagem foi enviada com sucesso | ||
} else { | ||
echo "Erro ao enviar a imagem."; | ||
return; | ||
} | ||
} | ||
$caminho = "http://localhost/tavola-redonda/assets/mapas/" . $imageName; | ||
if ($this->mapaModel->uploadMapa($nome, $caminho, $tipo, $user_id)) { | ||
header('Location: ../mapas/index.php'); | ||
exit(); | ||
} else { | ||
return "Erro ao adicionar o mapa."; | ||
} | ||
} | ||
} | ||
|
||
public function deleteMapa($mapa_id) { | ||
$this->mapaModel->deleteMapa($mapa_id); | ||
header('Location: ../mapas/index.php'); | ||
exit(); | ||
} | ||
|
||
public function listarMapas() { | ||
return $this->mapaModel->getAllMapas(); | ||
} | ||
} | ||
?> |
Oops, something went wrong.