-
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 #7 from comatic0/develop
Release 3.0.0
- Loading branch information
Showing
49 changed files
with
1,686 additions
and
511 deletions.
There are no files selected for viewing
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
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(); | ||
} | ||
} | ||
?> |
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,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; | ||
} | ||
} | ||
?> |
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,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); | ||
} | ||
} | ||
?> |
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,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(); | ||
} | ||
} | ||
} | ||
?> |
Oops, something went wrong.