diff --git a/home/app/controllers/RegisterController.php b/home/app/controllers/RegisterController.php index e6fa219..7d158f6 100644 --- a/home/app/controllers/RegisterController.php +++ b/home/app/controllers/RegisterController.php @@ -3,7 +3,7 @@ require_once __DIR__ . '/../../core/Controller.php'; class RegisterController extends Controller { public function index($urlToken = null) { - $token = trim($_GET['token'] ?? $urlToken ?? ''); + $token = trim($_GET['token'] ?? $_GET['TOKEN'] ?? $urlToken ?? ''); if (empty($token)) { $this->view('register', [ @@ -50,7 +50,7 @@ class RegisterController extends Controller { exit; } - $token = trim($_POST['token'] ?? ''); + $token = trim($_POST['token'] ?? $_POST['TOKEN'] ?? ''); $name = trim($_POST['name'] ?? ''); $email = trim(strtolower($_POST['email'] ?? '')); $password = $_POST['password'] ?? ''; diff --git a/home/app/models/Invitation.php b/home/app/models/Invitation.php index 4935947..b64942b 100644 --- a/home/app/models/Invitation.php +++ b/home/app/models/Invitation.php @@ -24,7 +24,7 @@ class Invitation { } public function getByToken(string $token): ?array { - $sql = "SELECT * FROM home_invitations WHERE token = :token"; + $sql = "SELECT * FROM home_invitations WHERE LOWER(token) = LOWER(:token)"; $this->db->query($sql); $this->db->bind(':token', $token); $invitation = $this->db->single(); @@ -52,7 +52,7 @@ class Invitation { } public function recordUse(string $token): bool { - $sql = "UPDATE home_invitations SET uses_count = uses_count + 1 WHERE token = :token"; + $sql = "UPDATE home_invitations SET uses_count = uses_count + 1 WHERE LOWER(token) = LOWER(:token)"; $this->db->query($sql); $this->db->bind(':token', $token); return $this->db->execute(); diff --git a/home/core/Router.php b/home/core/Router.php index 5628397..7e1414b 100644 --- a/home/core/Router.php +++ b/home/core/Router.php @@ -7,19 +7,25 @@ class Router { public function route() { $url = $this->parseUrl(); $controllerPath = __DIR__ . '/../app/controllers/'; - // Controller Check - if (isset($url[0]) && file_exists($controllerPath . ucfirst($url[0]) . 'Controller.php')) { - $this->controller = ucfirst($url[0]) . 'Controller'; - unset($url[0]); + // Controller Check (Case-insensitive) + if (isset($url[0])) { + $candidate = ucfirst(strtolower($url[0])) . 'Controller'; + if (file_exists($controllerPath . $candidate . '.php')) { + $this->controller = $candidate; + unset($url[0]); + } } require_once $controllerPath . $this->controller . '.php'; $this->controller = new $this->controller; - // Method Check + // Method Check (Case-insensitive) if (isset($url[1])) { $candidateMethod = $url[1]; - if (is_callable([$this->controller, $candidateMethod]) && strpos($candidateMethod, '_') !== 0) { - $this->method = $candidateMethod; - unset($url[1]); + foreach (get_class_methods($this->controller) as $methodName) { + if (strcasecmp($methodName, $candidateMethod) === 0 && strpos($methodName, '_') !== 0) { + $this->method = $methodName; + unset($url[1]); + break; + } } } // Params & Execution