diff --git a/src/Config/config.security.php b/src/Config/config.security.php index 45f0d88..d35bfd1 100644 --- a/src/Config/config.security.php +++ b/src/Config/config.security.php @@ -47,8 +47,8 @@ return array( | 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks */ 'csrf_protection' => true, - 'csrf_token_name' => 'csrf_test_name', - 'csrf_cookie_name' => 'csrf_cookie_name', + 'csrf_token_name' => 'fw_csrf_token', + 'csrf_cookie_name' => 'fw_csrf_cookie', 'csrf_expire' => 7200, 'csrf_regenerate' => TRUE, 'csrf_exclude_uris' => array(), diff --git a/src/FuzeWorks/Factory.php b/src/FuzeWorks/Factory.php index 5c013ae..e45e126 100644 --- a/src/FuzeWorks/Factory.php +++ b/src/FuzeWorks/Factory.php @@ -183,9 +183,9 @@ class Factory $this->language = new Language(); $this->utf8 = new Utf8(); $this->uri = new URI(); + $this->output = new Output(); $this->security = new Security(); $this->input = new Input(); - $this->output = new Output(); $this->router = new Router(); return true; diff --git a/src/FuzeWorks/Layout.php b/src/FuzeWorks/Layout.php index 5e1c1b1..b8d1aa0 100644 --- a/src/FuzeWorks/Layout.php +++ b/src/FuzeWorks/Layout.php @@ -166,6 +166,8 @@ class Layout $this->assigned_variables['serverName'] = $main_config->server_name; $this->assigned_variables['adminMail'] = $main_config->administrator_mail; $this->assigned_variables['contact'] = $contact_config->toArray(); + $this->assigned_variables['csrfTokenName'] = Factory::getInstance()->security->get_csrf_token_name(); + $this->assigned_variables['csrfHash'] = Factory::getInstance()->security->get_csrf_hash(); // Select an engine if one is not already selected if (is_null($this->current_engine)) { diff --git a/src/FuzeWorks/Logger.php b/src/FuzeWorks/Logger.php index 1d55f18..ee2f2ac 100644 --- a/src/FuzeWorks/Logger.php +++ b/src/FuzeWorks/Logger.php @@ -478,10 +478,11 @@ class Logger { /** * Calls an HTTP error, sends it as a header, and loads a template if required to do so. * - * @param int $errno HTTP error code - * @param bool $layout true to layout error on website + * @param int $errno HTTP error code + * @param string $message Additional message to the error + * @param bool $layout true to layout error on website */ - public static function http_error($errno = 500, $layout = true): bool + public static function http_error($errno = 500, $message = '', $layout = true): bool { $http_codes = array( 400 => 'Bad Request', @@ -536,10 +537,11 @@ class Logger { $factory = Factory::getInstance(); try { $factory->layout->reset(); + $factory->layout->assign('errorMessage', $message); $factory->layout->display($layout); } catch (LayoutException $exception) { // No error page could be found, just echo the result - $factory->output->set_output("

$errno

" . $http_codes[$errno] . '

'); + $factory->output->set_output("

$errno

" . $http_codes[$errno] . '

' . $message . '

'); } return true; diff --git a/src/FuzeWorks/Router.php b/src/FuzeWorks/Router.php index 85aa3a3..fd22670 100644 --- a/src/FuzeWorks/Router.php +++ b/src/FuzeWorks/Router.php @@ -364,6 +364,7 @@ class Router if ($performLoading === true) { $this->routeDefault(array_values($this->uri->segments), '.*$'); + return false; } } @@ -532,8 +533,15 @@ class Router // Check if method exists or if there is a caller function if (method_exists($this->callable, $event->function) || method_exists($this->callable, '__call')) { + // Run the routerCallMethodEvent + $methodEvent = Events::fireEvent('routerCallMethodEvent'); + if ($methodEvent->isCancelled()) + { + return; + } + // Execute the function on the controller - echo $this->callable->{$event->function}($event->parameters); + $this->output->append_output($this->callable->{$event->function}($event->parameters)); } else { // Function could not be found $this->logger->log('Could not find function '.$event->function.' on controller '.$event->className); diff --git a/src/FuzeWorks/Security.php b/src/FuzeWorks/Security.php index ff02e38..0e4535a 100644 --- a/src/FuzeWorks/Security.php +++ b/src/FuzeWorks/Security.php @@ -120,7 +120,7 @@ class Security { * * @var string */ - protected $_csrf_cookie_name = 'fw_csrf_token'; + protected $_csrf_cookie_name = 'fw_csrf_cookie'; /** * List of never allowed strings