Skip to content

Commit

Permalink
Merge pull request #7 from comatic0/develop
Browse files Browse the repository at this point in the history
Release 3.0.0
  • Loading branch information
comatic0 authored Oct 9, 2024
2 parents 6b792a0 + e8c1dda commit 821c7e9
Show file tree
Hide file tree
Showing 49 changed files with 1,686 additions and 511 deletions.
Binary file added assets/icons/eye-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/eye-slash-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/profile_pictures/FrodoBaggins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/profile_pictures/Testinhador.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/profile_pictures/bailand0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/profile_pictures/user-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/profile_pictures/user_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/profile_pictures/user_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/samples/frodobaggins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/samples/gandalf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions controllers/AuthController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
require_once __DIR__ . '/../models/User.php';
require_once __DIR__ . '/../includes/db.php';

class AuthController {
private $userModel;

public function __construct($pdo) {
$this->userModel = new User($pdo);
}


public function getUserByEmail($pdo, $email) {
$stmt = $pdo->prepare("SELECT * FROM usuarios WHERE email = ?");
$stmt->execute([$email]);
return $stmt->fetch(PDO::FETCH_ASSOC);
}

public function getUserById($user_id) {
$stmt = $this->userModel->getUserById($user_id);
return $stmt;
}

public function register($username, $email, $password) {
if ($this->userModel->getUserByEmail($email)) {
return "Email já está em uso.";
}
if ($this->userModel->getUserByUsername($username)) {
return "Nome de usuário já está em uso.";
}
if (strlen($password) < 8 || !preg_match('/[A-Z]/', $password) || !preg_match('/[0-9]/', $password)) {
return "A senha deve ter pelo menos 8 caracteres, incluindo uma letra maiúscula e um número.";
}
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
if ($this->userModel->createUser($username, $email, $hashedPassword)) {
header('Location: ../auth/login.php');
exit();
} else {
return "Erro ao registrar usuário.";
}
}

public function login($email, $password) {
$user = $this->userModel->getUserByEmail($email);
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
$_SESSION['profile_picture'] = $user['profile_picture'] ?? 'user-icon.png';
header('Location: ../../index.php');
exit();
} else {
return "Email ou senha incorretos.";
}
}

public function logout() {
session_start();
session_destroy();
header('Location: ../auth/login.php');
exit();
}
}
?>
31 changes: 31 additions & 0 deletions controllers/CalendarioController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
class CalendarioController {
public function gerarCalendario($mes, $ano) {
$diasNoMes = cal_days_in_month(CAL_GREGORIAN, $mes, $ano);
$diaDaSemana = date('w', mktime(0, 0, 0, $mes, 1, $ano));

$calendario = "<table>
<tr>
<th>Dom</th>
<th>Seg</th>
<th>Ter</th>
<th>Qua</th>
<th>Qui</th>
<th>Sex</th>
<th>Sáb</th>
</tr>
<tr>";

for ($i = 0; $i < $diaDaSemana; $i++) $calendario .= "<td></td>";
for ($dia = 1; $dia <= $diasNoMes; $dia++) {
if (($dia + $diaDaSemana - 1) % 7 == 0) $calendario .= "</tr><tr>";
$calendario .= "<td>$dia</td>";
}
while (($diaDaSemana + $diasNoMes) % 7 != 0) { $calendario .= "<td></td>"; $diasNoMes++; }

$calendario .= "</tr></table>";

return $calendario;
}
}
?>
27 changes: 27 additions & 0 deletions controllers/FichaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
require_once __DIR__ . '/../models/Ficha.php';
require_once __DIR__ . '/../includes/db.php';
class FichaController {
private $fichaModel;
public function __construct($pdo) {
$this->fichaModel = new Ficha($pdo);
}
public function createFicha($nome, $classe, $nivel, $raca, $descricao) {
$user_id = $_SESSION['user_id'] ?? null;
if ($user_id) {
if ($this->fichaModel->createFicha($nome, $classe, $nivel, $raca, $descricao, $user_id)) {
header('Location: ../fichas/index.php');
exit();
} else {
return "Erro ao criar personagem.";
}
}
}
public function getAllFichas() {
return $this->fichaModel->getAllFichas();
}
public function deleteFicha($id) {
return $this->fichaModel->deleteFicha($id);
}
}
?>
94 changes: 94 additions & 0 deletions controllers/MesaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
require_once __DIR__ . '/../models/Mesa.php';
require_once __DIR__ . '/../includes/db.php';

class MesaController {
private $mesaModel;

public function __construct($pdo) {
$this->mesaModel = new Mesa($pdo);
}

public function leaveMesa($mesa_id) {
$user_id = $_SESSION['user_id'] ?? null;
if ($mesa_id && $user_id) {
$this->mesaModel->leaveMesa($mesa_id, $user_id);
}
header('Location: ../mesas/index.php');
exit();
}

public function joinMesa($mesa_id) {
$user_id = $_SESSION['user_id'] ?? null;
if ($mesa_id && $user_id) {
$this->mesaModel->joinMesa($mesa_id, $user_id);
}
header('Location: ../mesas/index.php');
exit();
}

public function isUserInMesa($mesa_id, $user_id) {
return $this->mesaModel->isUserInMesa($mesa_id, $user_id);
}

public function getMesaParticipants($mesa_id) {
return $this->mesaModel->getMesaParticipants($mesa_id);
}

public function searchTables($search) {
return $this->mesaModel->searchTables($search);
}

public function getAllMesas() {
return $this->mesaModel->getAllMesas();
}

public function deleteMesa($mesa_id) {
$this->mesaModel->deleteMesa($mesa_id);
header('Location: ../mesas/index.php');
exit();
}

public function isAtMaxCapacity($mesa_id) {
return $this->mesaModel->isAtMaxCapacity($mesa_id);
}

public function createMesa($nome, $descricao, $categoria, $data_da_sessao, $max_capacity, $user_id) {
$nome_do_mestre = $this->mesaModel->getUserNameById($user_id);
$mesa_id = $this->mesaModel->createMesa($nome, $descricao, $categoria, $data_da_sessao, $max_capacity, $user_id, $nome_do_mestre);
if ($mesa_id) {
$this->mesaModel->joinMesa($mesa_id, $user_id); // Adiciona o mestre à mesa
}
return $mesa_id;
}

public function updateMesa($id, $nome, $descricao, $nome_do_mestre, $numero_max_jogadores, $categoria) {
$result = $this->mesaModel->updateTable($id, $nome, $descricao, $nome_do_mestre, $numero_max_jogadores, $categoria);
if ($result) {
error_log("Table with ID $id updated successfully.");
header('Location: index.php');
exit();
} else {
error_log("Failed to update table with ID $id.");
}
}

public function getMesaById($mesa_id) {
$table = $this->mesaModel->getTableById($mesa_id);
if ($table) {
return $table;
} else {
exit();
}
}

public function delete($user_id, $mesa_id) {
if ($this->mesaModel->deleteUser($user_id, $mesa_id)) {
header('Location: edit.php?id=' . $mesa_id);
} else {
header('Location: edit.php?id=' . $mesa_id);
exit();
}
}
}
?>
Loading

0 comments on commit 821c7e9

Please sign in to comment.