Fixed issue #117. Also made changes related to events.
This commit is contained in:
parent
f5a4c9b7f4
commit
9b923bdd20
@ -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(),
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -479,9 +479,10 @@ 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 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("<h1>$errno</h1><h3>" . $http_codes[$errno] . '</h3>');
|
||||
$factory->output->set_output("<h1>$errno</h1><h3>" . $http_codes[$errno] . '</h3><h4>' . $message . '</h4>');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user